/******************************************************************************
 * * sms_create.c - implementation of sms create functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "sms_include.h"

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create(lv_obj_t *pBtn,lv_event_t event)
{
    // Create message function
    // create Messages_Create_Message chart
    Nav_Func_List_t             FuncList;
    UI_Normal_NoTitle_Ta_Desc_t *pCreateMessage = NULL;

    if (LV_EVENT_CLICKED != event)
    {
        return;
    }

    pCreateMessage = (UI_Normal_NoTitle_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Ta_Desc_t));
    Hal_Mem_Set(pCreateMessage, 0, sizeof(UI_Normal_NoTitle_Ta_Desc_t));

    g_MsgGlobalCtrl.pChart = pCreateMessage;
    if (  (DISTRIBUTION_LISTS != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_DRAFTS != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_INBOX != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_SENT_ITEMS != g_MsgGlobalCtrl.CurOpenBox))
    {
        g_MsgGlobalCtrl.CurOpenBox = MSG_CREATE_MESSAGE_BOX;
    }

    pCreateMessage->ContLabelTl.TxtId       = LV_LANG_TXT_ID_NONE;
    pCreateMessage->ContLabelTl.SymbolId    = LV_SYMBOL_EDIT;
    pCreateMessage->ContLabelTl.SymbolAlign = LV_LABEL_ALIGN_LEFT;

    pCreateMessage->ContLabelTr.TxtId    = LV_LANG_TXT_ID_NONE;
    pCreateMessage->ContLabelTr.TxtAlign = LV_LABEL_ALIGN_CENTER;

    pCreateMessage->ContTa.TaCursorHide = FALSE;

    if (NULL != g_MsgGlobalCtrl.pSmsText)
    {
        pCreateMessage->ContTa.TaTxt            = g_MsgGlobalCtrl.pSmsText;
        pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    }
    else
    {
        pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
        pCreateMessage->ContTa.TaTxt            = "\0";
    }

    pCreateMessage->ButtonBar.ButtonL.TxtId      = PHONE_TEXT_ID_OPT;
    pCreateMessage->ButtonBar.ButtonL.ReleaseFun = NULL;
    pCreateMessage->ButtonBar.ButtonL.Valid      = true;

    pCreateMessage->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_SPELL;
    pCreateMessage->ButtonBar.ButtonM.ReleaseFun = NULL;
    pCreateMessage->ButtonBar.ButtonM.Valid      = true;

    pCreateMessage->ButtonBar.ButtonR.ReleaseFun = NULL;
    pCreateMessage->ButtonBar.ButtonR.Valid      = true;

    pCreateMessage->KeyFunc = Sms_Create_Handle;

    FuncList.OnShow   = (Void_P_Func_t)UI_Normal_NoTitle_Ta_Create;
    FuncList.OnHide   = NULL;
    FuncList.OnCreate = Sms_Create_On_Create;
    if (  (DISTRIBUTION_LISTS != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_DRAFTS != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_INBOX != g_MsgGlobalCtrl.CurOpenBox)
       && (MSG_SENT_ITEMS != g_MsgGlobalCtrl.CurOpenBox))
    {
        FuncList.OnDestroy = Sms_Common_All_Global_Destory;      // temp
    }
    else
    {
        FuncList.OnDestroy = Sms_Create_Destory;      // temp
    }

    FuncList.OnSaveState    = Sms_Create_On_Save;            // temp
    FuncList.OnRestoreState = Sms_Create_On_Create;          // temp

    // APP UI entry
    // create Messages chart
    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, &FuncList, (void *)pCreateMessage);
} /* Sms_Create */

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Create_Destory(VOID *pDesc)
{
    Sms_Common_Free_ContactInfo();
    g_MsgGlobalCtrl.SuccessCnt = 0;
    g_MsgGlobalCtrl.ContactCnt = 0;
    g_MsgGlobalCtrl.OtherAppUseType = 0;
    Sms_Common_Destory(pDesc);
}

/**
 * Common Process UI save event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Create_On_Save(VOID *pDesc)
{
    INT8                        str[]           = "\0";
    INT8                        *pTemp          = NULL;
    UI_Normal_NoTitle_Ta_Desc_t *pCreateMessage = pDesc;

    g_MsgGlobalCtrl.pChart = NULL;
    Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
    g_MsgGlobalCtrl.pSmsText = NULL;
    pTemp                    = (INT8 *)lv_textarea_get_text(pCreateMessage->ContTa.TextArea);
    if (false == strcmp(str, pTemp))
    {
        return;
    }
    g_MsgGlobalCtrl.pSmsText = Hal_Mem_Alloc(NV_SMS_MAX_INPUT_NUM);
    Hal_Mem_Set(g_MsgGlobalCtrl.pSmsText, 0, NV_SMS_MAX_INPUT_NUM);

    strcpy(g_MsgGlobalCtrl.pSmsText, pTemp);
}

/**
 * Process UI input char number event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Create_Input_char_Process(UINT8 Len)
{
    UINT32                      i = 0;
    INT8                        Temp[MSG_TEXT_INPUT_MAX_LEN];
    INT8                        *pTemp          = NULL;
    UI_Normal_NoTitle_Ta_Desc_t *pCreateMessage = g_MsgGlobalCtrl.pChart;

    pTemp = lv_label_get_text(pCreateMessage->ContLabelTr.Label);
    i     = atoi(pTemp);
    sprintf(Temp, "%d", (i - Len));
    lv_label_set_text(pCreateMessage->ContLabelTr.Label, Temp);
    if (PHONE_TEXT_ID_BACK == pCreateMessage->ButtonBar.ButtonR.TxtId)
    {
        lv_label_set_text((lv_obj_t *)pCreateMessage->ButtonBar.ButtonR.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_CLEAR));
        pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    }
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Create_On_Create(VOID *pDesc)
{
    UINT32                      i = 0;
    INT8                        Temp[MSG_TEXT_INPUT_MAX_LEN];

    UI_Normal_NoTitle_Ta_Desc_t *pCreateMessage = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pCreateMessage         = g_MsgGlobalCtrl.pChart;

    lv_obj_set_style_local_text_color(pCreateMessage->ContTa.TextArea,
                                     LV_TEXTAREA_PART_BG,
                                     LV_STATE_DEFAULT,
                                     LV_COLOR_BLACK);

    lv_obj_set_hidden(pCreateMessage->ButtonBar.ButtonM.Button, TRUE);

    if (NULL != g_MsgGlobalCtrl.pSmsText)
    {
        i = strlen(g_MsgGlobalCtrl.pSmsText);
        lv_textarea_set_text(pCreateMessage->ContTa.TextArea, g_MsgGlobalCtrl.pSmsText);
    }

    sprintf(Temp, "%d", MSG_INPUT_WORD_MAX_LEN - i);
    lv_label_set_text(pCreateMessage->ContLabelTr.Label, Temp);
    Ime_Set_GetCharLen_Func(Sms_Create_Input_char_Process);
    lv_textarea_set_max_length(pCreateMessage->ContTa.TextArea, MSG_INPUT_WORD_MAX_LEN);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Create_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                       Result = 0;
    UINT32                      i      = 0;
    INT8                        *pTemp;
    SMS_SIM_STATUS              SimStatus    = SMS_NO_SIM_PRESENT;
    IF_SETTING_DEFAULT_SIM      DefaultSim;
    MMI_MODEM_SIM_ID            TmpSimId;
    INT8                        Temp[MSG_TEXT_INPUT_MAX_LEN];
    UI_Normal_NoTitle_Ta_Desc_t *pCreateMessage = g_MsgGlobalCtrl.pChart;
    lv_obj_t *pBtn = NULL;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        switch (key_val)
        {
        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);
            i     = strlen(pTemp);

            if(i < MSG_INPUT_WORD_MAX_LEN)
            {
                sprintf(Temp, "%d", MSG_INPUT_WORD_MAX_LEN - i - 1);
            }
            else
            {
                sprintf(Temp, "%d", 0);
                Result = 1;
            }
            lv_label_set_text(pCreateMessage->ContLabelTr.Label, Temp);    // temp
            if (PHONE_TEXT_ID_BACK == pCreateMessage->ButtonBar.ButtonR.TxtId)
            {
                lv_label_set_text((lv_obj_t *)pCreateMessage->ButtonBar.ButtonR.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_CLEAR));
                pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
            }

            if (0)
            {                                                                       // temp
                lv_obj_set_hidden(pCreateMessage->ButtonBar.ButtonM.Button, FALSE); // temp
            }
            break;

        case KEY_SOFTRIGHT:
            pTemp = (INT8 *)lv_textarea_get_text(obj);
            if (strlen(pTemp) > 0)
            {
                lv_textarea_del_char(obj);

                pTemp = (INT8 *)lv_textarea_get_text(obj);
                i = strlen(pTemp);
                if (0 == i)
                {
                    lv_label_set_text((lv_obj_t *)pCreateMessage->ButtonBar.ButtonR.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_BACK));
                    pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
                }
                sprintf(Temp, "%d", MSG_INPUT_WORD_MAX_LEN - i);
                lv_label_set_text(pCreateMessage->ContLabelTr.Label, Temp);
            }
            else if (PHONE_TEXT_ID_CLEAR == pCreateMessage->ButtonBar.ButtonR.TxtId)
            {
                // released key after long pressed key
                lv_label_set_text((lv_obj_t *)pCreateMessage->ButtonBar.ButtonR.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_BACK));
                pCreateMessage->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
            }
            else if (PHONE_TEXT_ID_BACK == pCreateMessage->ButtonBar.ButtonR.TxtId)
            {
                Nav_Back(ACT_ID_ANY);
            }
            Result = 1;
            break;

        case KEY_SOFTLEFT:
            Sms_Create_Option();
            Result = 1;
            break;

        case KEY_DIAL:
            SimStatus = Sms_Get_Sim_Status();
            if (SMS_BOTH_SIM_PRESENT == SimStatus)
            {
                DefaultSim = Setting_Get_Default_Sim_Req(IF_SETTING_SERVICE_SMS);
                if (IF_SETTING_ASK_EVERY_TIME == DefaultSim)
                {
                    Sms_Create_Send(NULL,LV_EVENT_CLICKED);
                    Result = 1;
                    break;
                }
                else
                {
                    if (IF_SETTING_DEFAULT_SIM_1 == DefaultSim)
                    {
                        TmpSimId = MMI_MODEM_SIM_1;
                    }
                    else
                    {
                        TmpSimId = MMI_MODEM_SIM_2;
                    }
                }

            }
            else if (SMS_SIM1_PRESENT == SimStatus)
            {
                TmpSimId = MMI_MODEM_SIM_1;
            }
            else if (SMS_SIM2_PRESENT == SimStatus)
            {
                TmpSimId = MMI_MODEM_SIM_2;
            }
            else
            {
                Result = 1;
                break;
            }
            pBtn = (lv_obj_t *)Hal_Mem_Alloc(sizeof(lv_obj_t));
            pBtn->user_data.user_num = TmpSimId;

            Sms_Send_Sim_Select(pBtn,LV_EVENT_CLICKED);
            Hal_Mem_Free(pBtn);
            pBtn = NULL;
            Result = 1;
            break;

        case KEY_END:
            // save to drafts,temp
            Nav_Home(ACT_ID_ANY);
            Result = 1;
            break;

        case KEY_OK:
            Result = 1;
            break;

        default:
            break;
        } /* switch */
    }
    else if (KEY_LONGPRESS == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            lv_textarea_set_text(obj, "");
            sprintf(Temp, "%d", MSG_INPUT_WORD_MAX_LEN);
            lv_label_set_text(pCreateMessage->ContLabelTr.Label, Temp);
        }
    }
    return(Result);
} /* Sms_Create_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Create_Option(VOID)
{
    // Create message option function
    // Create Messages_Create_Message_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pCreateSmsOpt = NULL;
    UI_Button_Desc_t           *ButtonList    = NULL;
    SMS_SIM_STATUS              SimStatus    = SMS_NO_SIM_PRESENT;

    pCreateSmsOpt = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pCreateSmsOpt, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 8);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 8);

    g_MsgGlobalCtrl.pChart = pCreateSmsOpt;

    pCreateSmsOpt->TitleBar.TxtId      = PHONE_TEXT_ID_SMS;
    pCreateSmsOpt->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pCreateSmsOpt->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    SimStatus = Sms_Get_Sim_Status();
    if (DISTRIBUTION_LISTS == g_MsgGlobalCtrl.CurOpenBox)
    {
        if (SMS_NO_SIM_PRESENT == SimStatus)
        {
            ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 4);
            Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 4);
            pCreateSmsOpt->List.ListButtonCnt = 4;

            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
            ButtonList[0].ReleaseFun  = Sms_Create_Save_Messages;
            ButtonList[0].Valid       = true;
            ButtonList[1].ButtonIndex = 1;
            ButtonList[1].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
            ButtonList[1].ReleaseFun  = Sms_Create_Clear_Text;
            ButtonList[1].Valid       = true;
            ButtonList[2].ButtonIndex = 2;
            ButtonList[2].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
            ButtonList[2].ReleaseFun  = Sms_Create_Exit_Editor;
            ButtonList[2].Valid       = true;
            ButtonList[3].ButtonIndex = 3;
            ButtonList[3].TxtId       = PHONE_TEXT_ID_DICTIONARY;
            ButtonList[3].ReleaseFun  = Sms_Create_Dictionary;
            ButtonList[3].Valid       = true;
        }
        else
        {
            ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 6);
            Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 6);
            pCreateSmsOpt->List.ListButtonCnt = 6;

            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SEND;
            ButtonList[0].ReleaseFun  = Sms_Create_Send;
            ButtonList[0].Valid       = true;
            ButtonList[1].ButtonIndex = 1;
            ButtonList[1].TxtId       = PHONE_TEXT_ID_INSERT_OPT;
            ButtonList[1].ReleaseFun  = Sms_Create_Insert_Options;
            ButtonList[1].Valid       = true;
            ButtonList[2].ButtonIndex = 2;
            ButtonList[2].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
            ButtonList[2].ReleaseFun  = Sms_Create_Save_Messages;
            ButtonList[2].Valid       = true;
            ButtonList[3].ButtonIndex = 3;
            ButtonList[3].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
            ButtonList[3].ReleaseFun  = Sms_Create_Clear_Text;
            ButtonList[3].Valid       = true;
            ButtonList[4].ButtonIndex = 4;
            ButtonList[4].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
            ButtonList[4].ReleaseFun  = Sms_Create_Exit_Editor;
            ButtonList[4].Valid       = true;
            ButtonList[5].ButtonIndex = 5;
            ButtonList[5].TxtId       = PHONE_TEXT_ID_DICTIONARY;
            ButtonList[5].ReleaseFun  = Sms_Create_Dictionary;
            ButtonList[5].Valid       = true;
        }
    }
    else
    {
        if (MSG_DICTIONARY_ENB == g_MsgGlobalCtrl.DictionaryFlg)
        {
            if (SMS_NO_SIM_PRESENT == SimStatus)
            {
                ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 6);
                Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 6);
                pCreateSmsOpt->List.ListButtonCnt = 6;

                ButtonList[0].ButtonIndex = 0;
                ButtonList[0].TxtId       = PHONE_TEXT_ID_INSERT_OPT;
                ButtonList[0].ReleaseFun  = Sms_Create_Insert_Options;
                ButtonList[0].Valid       = true;
                ButtonList[1].ButtonIndex = 1;
                ButtonList[1].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
                ButtonList[1].ReleaseFun  = Sms_Create_Save_Messages;
                ButtonList[1].Valid       = true;
                ButtonList[2].ButtonIndex = 2;
                ButtonList[2].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
                ButtonList[2].ReleaseFun  = Sms_Create_Clear_Text;
                ButtonList[2].Valid       = true;
                ButtonList[3].ButtonIndex = 3;
                ButtonList[3].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
                ButtonList[3].ReleaseFun  = Sms_Create_Exit_Editor;
                ButtonList[3].Valid       = true;
                ButtonList[4].ButtonIndex = 4;
                ButtonList[4].TxtId       = PHONE_TEXT_ID_DICTIONARY;
                ButtonList[4].ReleaseFun  = Sms_Create_Dictionary;
                ButtonList[4].Valid       = true;
                ButtonList[5].ButtonIndex = 5;
                ButtonList[5].TxtId       = PHONE_TEXT_ID_MATCHES;
                ButtonList[5].ReleaseFun  = Sms_Create_Matches_Body;
                ButtonList[5].Valid       = true;
            }
            else
            {
                ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 8);
                Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 8);
                pCreateSmsOpt->List.ListButtonCnt = 8;

                ButtonList[0].ButtonIndex = 0;
                ButtonList[0].TxtId       = PHONE_TEXT_ID_SEND;
                ButtonList[0].ReleaseFun  = Sms_Create_Send;
                ButtonList[0].Valid       = true;
                ButtonList[1].ButtonIndex = 1;
                ButtonList[1].TxtId       = PHONE_TEXT_ID_SENDING_OPT;
                ButtonList[1].ReleaseFun  = Sms_Create_Sending_Option;
                ButtonList[1].Valid       = true;
                ButtonList[2].ButtonIndex = 2;
                ButtonList[2].TxtId       = PHONE_TEXT_ID_INSERT_OPT;
                ButtonList[2].ReleaseFun  = Sms_Create_Insert_Options;
                ButtonList[2].Valid       = true;
                ButtonList[3].ButtonIndex = 3;
                ButtonList[3].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
                ButtonList[3].ReleaseFun  = Sms_Create_Save_Messages;
                ButtonList[3].Valid       = true;
                ButtonList[4].ButtonIndex = 4;
                ButtonList[4].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
                ButtonList[4].ReleaseFun  = Sms_Create_Clear_Text;
                ButtonList[4].Valid       = true;
                ButtonList[5].ButtonIndex = 5;
                ButtonList[5].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
                ButtonList[5].ReleaseFun  = Sms_Create_Exit_Editor;
                ButtonList[5].Valid       = true;
                ButtonList[6].ButtonIndex = 6;
                ButtonList[6].TxtId       = PHONE_TEXT_ID_DICTIONARY;
                ButtonList[6].ReleaseFun  = Sms_Create_Dictionary;
                ButtonList[6].Valid       = true;
                ButtonList[7].ButtonIndex = 7;
                ButtonList[7].TxtId       = PHONE_TEXT_ID_MATCHES;
                ButtonList[7].ReleaseFun  = Sms_Create_Matches_Body;
                ButtonList[7].Valid       = true;
            }
        }
        else
        {
            if (SMS_NO_SIM_PRESENT == SimStatus)
            {
                ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 5);
                Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 5);
                pCreateSmsOpt->List.ListButtonCnt = 5;

                ButtonList[0].ButtonIndex = 0;
                ButtonList[0].TxtId       = PHONE_TEXT_ID_INSERT_OPT;
                ButtonList[0].ReleaseFun  = Sms_Create_Insert_Options;
                ButtonList[0].Valid       = true;
                ButtonList[1].ButtonIndex = 1;
                ButtonList[1].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
                ButtonList[1].ReleaseFun  = Sms_Create_Save_Messages;
                ButtonList[1].Valid       = true;
                ButtonList[2].ButtonIndex = 2;
                ButtonList[2].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
                ButtonList[2].ReleaseFun  = Sms_Create_Clear_Text;
                ButtonList[2].Valid       = true;
                ButtonList[3].ButtonIndex = 3;
                ButtonList[3].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
                ButtonList[3].ReleaseFun  = Sms_Create_Exit_Editor;
                ButtonList[3].Valid       = true;
                ButtonList[4].ButtonIndex = 4;
                ButtonList[4].TxtId       = PHONE_TEXT_ID_DICTIONARY;
                ButtonList[4].ReleaseFun  = Sms_Create_Dictionary;
                ButtonList[4].Valid       = true;
            }
            else
            {
                ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 7);
                Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 7);
                pCreateSmsOpt->List.ListButtonCnt = 7;

                ButtonList[0].ButtonIndex = 0;
                ButtonList[0].TxtId       = PHONE_TEXT_ID_SEND;
                ButtonList[0].ReleaseFun  = Sms_Create_Send;
                ButtonList[0].Valid       = true;
                ButtonList[1].ButtonIndex = 1;
                ButtonList[1].TxtId       = PHONE_TEXT_ID_SENDING_OPT;
                ButtonList[1].ReleaseFun  = Sms_Create_Sending_Option;
                ButtonList[1].Valid       = true;
                ButtonList[2].ButtonIndex = 2;
                ButtonList[2].TxtId       = PHONE_TEXT_ID_INSERT_OPT;
                ButtonList[2].ReleaseFun  = Sms_Create_Insert_Options;
                ButtonList[2].Valid       = true;
                ButtonList[3].ButtonIndex = 3;
                ButtonList[3].TxtId       = PHONE_TEXT_ID_SAVE_SMS;
                ButtonList[3].ReleaseFun  = Sms_Create_Save_Messages;
                ButtonList[3].Valid       = true;
                ButtonList[4].ButtonIndex = 4;
                ButtonList[4].TxtId       = PHONE_TEXT_ID_CLEAR_TEXT;
                ButtonList[4].ReleaseFun  = Sms_Create_Clear_Text;
                ButtonList[4].Valid       = true;
                ButtonList[5].ButtonIndex = 5;
                ButtonList[5].TxtId       = PHONE_TEXT_ID_EXIT_EDITOR;
                ButtonList[5].ReleaseFun  = Sms_Create_Exit_Editor;
                ButtonList[5].Valid       = true;
                ButtonList[6].ButtonIndex = 6;
                ButtonList[6].TxtId       = PHONE_TEXT_ID_DICTIONARY;
                ButtonList[6].ReleaseFun  = Sms_Create_Dictionary;
                ButtonList[6].Valid       = true;
            }
        }
    }
    pCreateSmsOpt->List.Index      = 0;
    pCreateSmsOpt->List.ButtonList = ButtonList;

    pCreateSmsOpt->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pCreateSmsOpt->BtnBar.ButtonR.Valid = true;

    pCreateSmsOpt->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pCreateSmsOpt->BtnBar.ButtonM.Valid = true;

    pCreateSmsOpt->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE_OPT, &FuncList, (void *)pCreateSmsOpt);
} /* Sms_Create_Option */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Create_Opt_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Create_Spell(lv_obj_t *pBtn)
{
    // Insert word
    // create Messages_Insert_Word chart
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Send(lv_obj_t *pBtn,lv_event_t event)
{
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pCreateSend = NULL;
    UI_Button_Desc_t           *ButtonList  = NULL;
    SMS_SIM_STATUS             SimStatus    = SMS_NO_SIM_PRESENT;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // send message function,the sim selection chart
    pCreateSend = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pCreateSend, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_MsgGlobalCtrl.pChart = pCreateSend;

    pCreateSend->TitleBar.TxtId      = PHONE_TEXT_ID_SIM_SEL;
    pCreateSend->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pCreateSend->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    SimStatus = Sms_Get_Sim_Status();
    if (SMS_SIM1_PRESENT == (SimStatus & SMS_SIM1_PRESENT))
    {
        pCreateSend->List.ListButtonCnt++;
    }
    if (SMS_SIM2_PRESENT == (SimStatus & SMS_SIM2_PRESENT))
    {
        pCreateSend->List.ListButtonCnt++;
    }

    if (pCreateSend->List.ListButtonCnt)
    {
        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * pCreateSend->List.ListButtonCnt);
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * pCreateSend->List.ListButtonCnt);
        pCreateSend->List.Index      = 0;
        pCreateSend->List.ButtonList = ButtonList;

        if (DISTRIBUTION_LISTS == g_MsgGlobalCtrl.CurOpenBox)
        {
            if (SMS_BOTH_SIM_PRESENT == SimStatus)
            {
                ButtonList[0].ReleaseFun = Sms_Send_To_List_Distribution_Cnf;
                ButtonList[1].ReleaseFun = Sms_Send_To_List_Distribution_Cnf;
            }
            else
            {
                ButtonList[0].ReleaseFun = Sms_Send_To_List_Distribution_Cnf;
            }
        }
        else
        {
            if (SMS_BOTH_SIM_PRESENT == SimStatus)
            {
                ButtonList[0].ReleaseFun = Sms_Send_Sim_Select;
                ButtonList[1].ReleaseFun = Sms_Send_Sim_Select;
            }
            else
            {
                ButtonList[0].ReleaseFun = Sms_Send_Sim_Select;
            }
        }
        if (SMS_BOTH_SIM_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;

            ButtonList[1].ButtonIndex = 1;
            ButtonList[1].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[1].SymbolId1   = SYMBOL_SIM2;
            ButtonList[1].Valid       = true;
        }
        else if (SMS_SIM1_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;
        }
        else if (SMS_SIM2_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[0].SymbolId1   = SYMBOL_SIM2;
            ButtonList[0].Valid       = true;
        }
    }

    pCreateSend->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pCreateSend->BtnBar.ButtonR.Valid = true;

    if(SimStatus != SMS_NO_SIM_PRESENT)
    {
        pCreateSend->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
        pCreateSend->BtnBar.ButtonM.Valid = true;
    }
    else
    {
        pCreateSend->BtnBar.ButtonM.Valid = false;
    }

    pCreateSend->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Create_Send_To_Many_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory;   // temp
    FuncList.OnSaveState    = Sms_Common_Save;                // temp
    FuncList.OnRestoreState = Sms_Create_Send_To_Many_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SIM_SELECTION, &FuncList, (void *)pCreateSend);
} /* Sms_Create_Send */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_Sim_Select(lv_obj_t *pBtn,lv_event_t event)
{
    // Sim selection call back function
    // create Message_Phone_Number chart
    Nav_Func_List_t                   FuncList;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pPhoneNum = (UI_Normal_NoTitle_Label_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));
    Hal_Mem_Set(pPhoneNum, 0, sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));

    g_MsgGlobalCtrl.pChart = pPhoneNum;

    g_MsgGlobalCtrl.CurrSimId = (MMI_MODEM_SIM_ID)pBtn->user_data.user_num;    // store the sim id

    pPhoneNum->ContLabelTl.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;
    pPhoneNum->ContLabelTl.TxtId       = LV_LANG_TXT_ID_NONE;
    pPhoneNum->ContLabelTl.SymbolAlign = LV_LABEL_ALIGN_CENTER;
    pPhoneNum->ContLabelTl.SymbolId    = LV_SYMBOL_EDIT; // temp

    pPhoneNum->ContLabelTr.LabelAlign = LV_ALIGN_IN_TOP_RIGHT;
    pPhoneNum->ContLabelTr.TxtId      = LV_LANG_TXT_ID_NONE;
    pPhoneNum->ContLabelTr.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    pPhoneNum->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pPhoneNum->ContLabel.TxtId      = PHONE_TEXT_ID_PHONE_NUM;
    pPhoneNum->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pPhoneNum->ContTa.TaCursorHide  = FALSE;
    pPhoneNum->ContTa.TaTxt         = NULL;

    pPhoneNum->ButtonCont.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pPhoneNum->ButtonCont.ButtonL.Valid = true;

    pPhoneNum->ButtonCont.ButtonM.TxtId = PHONE_TEXT_ID_SEARCH;
    pPhoneNum->ButtonCont.ButtonM.Valid = true;

    pPhoneNum->ButtonCont.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    pPhoneNum->ButtonCont.ButtonR.Valid = true;

    pPhoneNum->KeyFunc = Sms_Create_Phone_Num_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Label_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Phone_Num_On_Create;
    FuncList.OnDestroy      = Sms_Phone_Num_On_Destory;      // temp
    FuncList.OnSaveState    = Sms_Phone_Num_On_Save;   // temp
    FuncList.OnRestoreState = Sms_Phone_Num_On_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_PHONE_NUMBER, &FuncList, (void *)pPhoneNum);
} /* Sms_Send_Sim_Select */

/**
 * Process UI input char number event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Phone_Num_Input_char_Process(UINT8 Len)
{
    UINT32                            i = 0;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    INT8                              *pTemp     = NULL;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = g_MsgGlobalCtrl.pChart;

    pTemp = lv_label_get_text(pPhoneNum->ContLabelTr.Label);
    i     = atoi(pTemp);
    sprintf(Temp, "%d", (i - Len));
    lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
    lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OK));
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Phone_Num_On_Create(VOID *pDesc)
{
    UINT32                            i = 0;
    INT8                              Temp1[MSG_TEXT_INPUT_MAX_LEN];

    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pPhoneNum              = g_MsgGlobalCtrl.pChart;

    lv_textarea_set_accepted_chars(pPhoneNum->ContTa.TextArea, g_AcceptInputNum);
    lv_textarea_set_max_length(pPhoneNum->ContTa.TextArea, MSG_INPUT_PHONE_NUM_MAX_LEN);

    if (NULL != g_MsgGlobalCtrl.pContact)
    {
        i = strlen(g_MsgGlobalCtrl.pContact);
        lv_textarea_set_text(pPhoneNum->ContTa.TextArea, g_MsgGlobalCtrl.pContact);
        lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OK));
    }
    else
    {
        if(NULL != g_MsgGlobalCtrl.pContactTa)
        {
            i = strlen(g_MsgGlobalCtrl.pContactTa);
            lv_textarea_set_text(pPhoneNum->ContTa.TextArea, g_MsgGlobalCtrl.pContactTa);
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OK));
        }
        else
        {
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEARCH));
        }
    }
    sprintf(Temp1, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN - i);
    lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp1);
    Ime_Set_GetCharLen_Func(Sms_Phone_Num_Input_char_Process);
    Ime_Set_Mode(LV_IME_MODE_NUM);
}

/**
 * Common Process UI save event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Phone_Num_On_Save(VOID *pDesc)
{
    INT8                        str[]           = "\0";
    INT8                        *pTemp          = NULL;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = pDesc;

    g_MsgGlobalCtrl.pChart = NULL;

    pTemp                    = (INT8 *)lv_textarea_get_text(pPhoneNum->ContTa.TextArea);
    if (false == strcmp(str, pTemp))
    {
        return;
    }
    Hal_Mem_Free(g_MsgGlobalCtrl.pContactTa);
    g_MsgGlobalCtrl.pContactTa = NULL;
    g_MsgGlobalCtrl.pContactTa = Hal_Mem_Alloc(MSG_INPUT_PHONE_NUM_MAX_LEN + 1);
    Hal_Mem_Set(g_MsgGlobalCtrl.pContactTa, 0, MSG_INPUT_PHONE_NUM_MAX_LEN + 1);

    strcpy(g_MsgGlobalCtrl.pContactTa, pTemp);
}

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Phone_Num_On_Destory(VOID *pDesc)
{
    Hal_Mem_Free(g_MsgGlobalCtrl.pContactTa);
    g_MsgGlobalCtrl.pContactTa = NULL;
    Sms_Common_Destory(pDesc);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  UINT8
 */
UINT8 Sms_Create_Phone_Num_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                             Result = 0;
    UINT32                            i      = 0;
    INT8                              *pTemp;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = g_MsgGlobalCtrl.pChart;    // temp

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        switch (key_val)
        {
        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);// temp
            i     = strlen(pTemp);
            if(i < MSG_INPUT_PHONE_NUM_MAX_LEN)
            {
                sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN - i - 1);
            }
            else
            {
                sprintf(Temp, "%d", 0);
                Result = 1;
            }
            lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OK));
            break;

        case KEY_SOFTRIGHT:
            lv_textarea_del_char(obj);
            pTemp = (INT8 *)lv_textarea_get_text(obj);
            i     = strlen(pTemp);
            if (0 == i)
            {            // clear all
                lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEARCH));
            }
            sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN - i);
            lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
            Result = 1;
            break;

        case KEY_SOFTLEFT:
            Nav_Back(ACT_ID_ANY);
            Result = 1;
            break;

        case KEY_OK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);        // temp
            i     = strlen(pTemp);
            if (i)
            {            // ok
                Hal_Mem_Free(g_MsgGlobalCtrl.pContact);
                g_MsgGlobalCtrl.pContact = NULL;
                g_MsgGlobalCtrl.pContact = Hal_Mem_Alloc(MSG_INPUT_PHONE_NUM_MAX_LEN + 1);
                Hal_Mem_Set(g_MsgGlobalCtrl.pContact, 0, MSG_INPUT_PHONE_NUM_MAX_LEN + 1);
                strcpy(g_MsgGlobalCtrl.pContact, pTemp);
                Sms_Create_Send_Phone_Num_OK();
            }
            else
            {            // search
                g_MsgGlobalCtrl.SelContactType = IF_CONTACTS_SMS_SEL_ONE_CONTACT;
                Contacts_Select_Contact_Req(IF_CONTACTS_SMS_SEL_ONE_CONTACT);
            }
            Result = 1;
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            Result = 1;
            break;

        default:
            break;
        } /* switch */
    }
    else if (KEY_LONGPRESS == key_sta)
    {    // clear all
        if (KEY_SOFTRIGHT == key_val)
        {
            lv_textarea_set_text(obj, "");
            sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN);
            lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEARCH));
        }
    }
    return(Result);   // temp
} /* Sms_Create_Phone_Num_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Create_Send_Phone_Num_OK(VOID)
{
    // Create Messages_Sending_Message chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pSendSts = NULL;

    pSendSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pSendSts, 0, sizeof(UI_Status_Desc_t));

    pSendSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pSendSts->ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    pSendSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pSendSts->ContLabelAlign       = LV_ALIGN_IN_TOP_MID;

    pSendSts->ContImg.Img      = IMG_PROGRESS_BAR;
    pSendSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pSendSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    pSendSts->KeyFunc = Sms_Create_Send_Phone_Num_OK_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_MESSAGE, &FuncList, (void *)pSendSts);

    if (MMI_MODEM_SIM_1 == g_MsgGlobalCtrl.CurrSimId)
    {
        lv_label_set_text(pSendSts->ContLabel.Label, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEND_SMS_BY_SIM1));
    }
    else
    {
        lv_label_set_text(pSendSts->ContLabel.Label, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEND_SMS_BY_SIM2));
    }

    Sms_Com_Send_Sms_To_One_Req();
}
/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Create_Send_Phone_Num_OK_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}
/**
 * sub-module entry
 * param (in) MMI_MODEM_SMS_RESULT_TYPE Result
 * return  VOID
 */
VOID Sms_Create_Message_Sent_Result(MMI_MODEM_SMS_RESULT_TYPE Result)
{
    // go to message sent chart,sent message result
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pSendResult = NULL;
    CB_FUNC          callback     = Sms_Create_Message_Sent_Result_Timeout;

    pSendResult = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pSendResult, 0, sizeof(UI_Status_Desc_t));

    pSendResult->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pSendResult->ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    pSendResult->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pSendResult->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    if (MMI_MODEM_SMS_FAIL == Result)
    {
        pSendResult->ContImg.Img = LV_SYMBOL_WARNING;
    }
    else
    {
        pSendResult->ContImg.Img = SYMBOL_CHECKED;
    }

    pSendResult->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pSendResult->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    if (MMI_MODEM_SMS_FAIL == Result)
    {
        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_MESSAGE_NOT_SENT, &FuncList, (void *)pSendResult);
        lv_label_set_text(pSendResult->ContLabel.Label, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_MESSAGE_SENT_FAIL));
        // start 2s timer
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_MESSAGE_NOT_SENT);
    }
    else
    {
        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_MESSAGE_SENT, &FuncList, (void *)pSendResult);
        lv_label_set_text(pSendResult->ContLabel.Label, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_MESSAGE_SENT));
        // start 2s timer
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_MESSAGE_SENT);
    }
} /* Sms_Create_Message_Sent_Result */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Create_Message_Sent_Result_Timeout(VOID* id)
{
    // go to Messages chart
    UINT32* Id = (UINT32 *)id;
    switch (g_MsgGlobalCtrl.OtherAppUseType)
    {
    case CONTACTS_SMS_REQ:
        Nav_Forward(*Id, ACT_ID_CONTACTS_DETAILS_OPTION, NULL, NULL);
        break;
    case CONTACTS_SHARE_VIA_SMS_REQ:
        Nav_Forward(*Id, ACT_ID_CONTACTS_DETAILS_OPTION, NULL, NULL);
        break;
    case CALL_SEND_SMS_REQ:
        Nav_Forward(*Id, ACT_ID_CALL_LOG_OPT, NULL, NULL);
        break;
    case FRAMEWORK_SMS_SEND_MESSAGE_REQ:
        Nav_Forward(*Id, ACT_ID_DESKTOP, NULL, NULL);
        break;
    default:
        if(NULL == Nav_Get_Param(ACT_ID_MESSAGES))
        {
            Nav_Forward(*Id, ACT_ID_DESKTOP, NULL, NULL);
        }
        else
        {
            Nav_Forward(*Id, ACT_ID_MESSAGES, NULL, NULL);
        }
        break;
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Sending_Option(lv_obj_t *pBtn,lv_event_t event)
{
    // sending option function
    // create Messages_Sending_Options chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pCreateSendOpt = NULL;
    UI_Button_Desc_t           *ButtonList     = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pCreateSendOpt = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pCreateSendOpt, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    g_MsgGlobalCtrl.pChart = pCreateSendOpt;

    pCreateSendOpt->TitleBar.TxtId      = PHONE_TEXT_ID_SENDING_OPT;
    pCreateSendOpt->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pCreateSendOpt->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pCreateSendOpt->List.ListButtonCnt = 2;
    pCreateSendOpt->List.Index         = 0;
    pCreateSendOpt->List.ButtonList    = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_SEND_TO_MANY;
    ButtonList[0].ReleaseFun  = Sms_Create_Send_To_Many;
    ButtonList[0].Valid       = true;

    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_SEND_TO_LIST;
    ButtonList[1].ReleaseFun  = Sms_Create_Send_To_List;
    ButtonList[1].Valid       = true;

    pCreateSendOpt->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pCreateSendOpt->BtnBar.ButtonR.Valid = true;

    pCreateSendOpt->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pCreateSendOpt->BtnBar.ButtonM.Valid = true;

    pCreateSendOpt->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_OPTIONS, &FuncList, (void *)pCreateSendOpt);
} /* Sms_Create_Sending_Option */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Send_To_Many(lv_obj_t *pBtn,lv_event_t event)
{
    // send to many function,sim selection chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pSendToMany = NULL;
    UI_Button_Desc_t           *ButtonList  = NULL;
    SMS_SIM_STATUS             SimStatus    = SMS_NO_SIM_PRESENT;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pSendToMany = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSendToMany, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_MsgGlobalCtrl.pChart = pSendToMany;

    pSendToMany->TitleBar.TxtId      = PHONE_TEXT_ID_SIM_SEL;
    pSendToMany->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSendToMany->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    SimStatus = Sms_Get_Sim_Status();
    if (SMS_SIM1_PRESENT == (SimStatus & SMS_SIM1_PRESENT))
    {
        pSendToMany->List.ListButtonCnt++;
    }
    if (SMS_SIM2_PRESENT == (SimStatus & SMS_SIM2_PRESENT))
    {
        pSendToMany->List.ListButtonCnt++;
    }
    if (pSendToMany->List.ListButtonCnt)
    {
        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * pSendToMany->List.ListButtonCnt);
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * pSendToMany->List.ListButtonCnt);
        pSendToMany->List.Index      = 0;
        pSendToMany->List.ButtonList = ButtonList;

        if (SMS_BOTH_SIM_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_Many_Sim_Select;

            ButtonList[1].ButtonIndex = 1;
            ButtonList[1].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[1].SymbolId1   = SYMBOL_SIM2;
            ButtonList[1].Valid       = true;
            ButtonList[1].ReleaseFun  = Sms_Send_To_Many_Sim_Select;
        }
        else if (SMS_SIM1_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_Many_Sim_Select;
        }
        else if (SMS_SIM2_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[0].SymbolId1   = SYMBOL_SIM2;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_Many_Sim_Select;
        }
    }

    pSendToMany->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pSendToMany->BtnBar.ButtonR.Valid = true;

    if(SimStatus != SMS_NO_SIM_PRESENT)
    {
        pSendToMany->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
        pSendToMany->BtnBar.ButtonM.Valid = true;
    }
    else
    {
        pSendToMany->BtnBar.ButtonM.Valid = false;
    }

    pSendToMany->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Create_Send_To_Many_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory;   // temp
    FuncList.OnSaveState    = Sms_Common_Save;                // temp
    FuncList.OnRestoreState = Sms_Create_Send_To_Many_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SIM_SELECTION, &FuncList, (void *)pSendToMany);
} /* Sms_Create_Send_To_Many */

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Create_Send_To_Many_Create(VOID *pDesc)
{
    UI_Normal_List_Only_Desc_t *pSendToMany = NULL;
    SMS_SIM_STATUS             SimStatus    = SMS_NO_SIM_PRESENT;

    g_MsgGlobalCtrl.pChart = pDesc;
    pSendToMany            = g_MsgGlobalCtrl.pChart;

    SimStatus = Sms_Get_Sim_Status();
    if (SMS_BOTH_SIM_PRESENT == SimStatus)
    {
        pSendToMany->List.ButtonList[0].Button->user_data.user_num = MMI_MODEM_SIM_1;
        pSendToMany->List.ButtonList[1].Button->user_data.user_num = MMI_MODEM_SIM_2;
    }
    else if (SMS_SIM1_PRESENT == SimStatus)
    {
        pSendToMany->List.ButtonList[0].Button->user_data.user_num = MMI_MODEM_SIM_1;
    }
    else if (SMS_SIM2_PRESENT == SimStatus)
    {
        pSendToMany->List.ButtonList[0].Button->user_data.user_num = MMI_MODEM_SIM_2;
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_Many_Sim_Select(lv_obj_t *pBtn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // Sim selection call back function
    // go to Contacts function

    g_MsgGlobalCtrl.CurrSimId      = (MMI_MODEM_SIM_ID)pBtn->user_data.user_num; // store the sim id
    g_MsgGlobalCtrl.SelContactType = IF_CONTACTS_SMS_SEL_MULTI_CONTACTS;
    Contacts_Select_Contact_Req(IF_CONTACTS_SMS_SEL_MULTI_CONTACTS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Sts(VOID)
{
    // go to messages sending status chart,sent messages
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pSendingSts = NULL;

    pSendingSts = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pSendingSts, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pSendingSts;

    pSendingSts->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pSendingSts->ContenCont.ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    pSendingSts->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pSendingSts->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_MID;

    pSendingSts->ContenCont.ContImg.Img      = IMG_PROGRESS_BAR;
    pSendingSts->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pSendingSts->ContenCont.ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    pSendingSts->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_STOP;
    pSendingSts->ButtonBar.ButtonR.Valid = true;

    pSendingSts->KeyFunc = Sms_Send_To_Many_Sending_Sts_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Send_To_Many_Sending_Sts_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory;                     // temp
    FuncList.OnSaveState    = Sms_Common_Save;                        // temp
    FuncList.OnRestoreState = Sms_Send_To_Many_Sending_Sts_On_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_STATUS, &FuncList, (void *)pSendingSts);
} /* Sms_Send_To_Many_Sending_Sts */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Send_To_Many_Sending_Sts_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Sms_Send_To_Many_Sending_Sts_Stop(NULL);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Send_To_Many_Sending_Sts_On_Create(VOID *pDesc)
{
    INT8                     *str         = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SENDING_TO_LIST);
    INT8                     *str1        = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_LEFT);
    INT8                     *pTemp       = Hal_Mem_Alloc(50);
    INT8                     *pTemp1      = Hal_Mem_Alloc(30);
    UINT16                   Temp         = 0;
    UI_Normal_NoTitle_Desc_t *pSendingSts = pDesc;

    g_MsgGlobalCtrl.pChart = pSendingSts;

    Hal_Mem_Set(pTemp, 0, 50);
    Hal_Mem_Set(pTemp1, 0, 30);
    strcpy(pTemp, str);

    Temp = g_MsgGlobalCtrl.ContactCnt - g_MsgGlobalCtrl.SendCnt;
    sprintf(pTemp1, "%d", Temp);
    strcat(pTemp, pTemp1);
    strcat(pTemp, str1);
    lv_label_set_text(pSendingSts->ContenCont.ContLabel.Label, pTemp);
    Hal_Mem_Free(pTemp);
    pTemp = NULL;
    Hal_Mem_Free(pTemp1);
    pTemp1 = NULL;
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Send_To_Many_Sending_Sts_Stop(lv_obj_t *pBtn)
{
    // Stop sent messages
    // create Messages_Sending_Result chart

    g_MsgGlobalCtrl.pCurrentSend = NULL;

    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pSendingResult = NULL;
    CB_FUNC          callback        = Sms_Send_To_Many_Sending_Rep_Timeout;

    pSendingResult = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pSendingResult, 0, sizeof(UI_Status_Desc_t));

    pSendingResult->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pSendingResult->ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    pSendingResult->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pSendingResult->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pSendingResult->ContImg.Img = IMG_PROGRESS_BAR;

    pSendingResult->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pSendingResult->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Send_To_Many_Sending_Sts_Stop_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory;                          // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;                             // temp
    FuncList.OnRestoreState = Sms_Send_To_Many_Sending_Sts_Stop_On_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_RESULT, &FuncList, (void *)pSendingResult);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_SENDING_RESULT);

    return(LV_RES_OK);
} /* Sms_Send_To_Many_Sending_Sts_Stop */

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Send_To_Many_Sending_Sts_Stop_On_Create(VOID *pDesc)
{
    INT8             *str    = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OUT_OF);
    INT8             *str1   = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SPACE_SENT);
    INT8             *pTemp  = Hal_Mem_Alloc(50);
    INT8             *pTemp1 = Hal_Mem_Alloc(30);
    INT8             *pTemp2 = Hal_Mem_Alloc(30);
    UINT16           Temp;
    UI_Status_Desc_t *pSendingResult = pDesc;

    g_MsgGlobalCtrl.pChart = pSendingResult;

    Hal_Mem_Set(pTemp, 0, 50);
    Hal_Mem_Set(pTemp1, 0, 30);
    Hal_Mem_Set(pTemp2, 0, 30);

    Temp = g_MsgGlobalCtrl.SendCnt;
    sprintf(pTemp1, "%d", Temp);
    strcpy(pTemp, pTemp1);
    strcat(pTemp, str);
    if (true == g_MsgGlobalCtrl.ResendFlg)
    {
        Temp = g_MsgGlobalCtrl.ResendCnt;
    }
    else
    {
        Temp = g_MsgGlobalCtrl.ContactCnt;
    }

    sprintf(pTemp2, "%d", Temp);
    strcat(pTemp, pTemp2);
    strcat(pTemp, str1);
    lv_label_set_text(pSendingResult->ContLabel.Label, pTemp);
    Hal_Mem_Free(pTemp);
    pTemp = NULL;
    Hal_Mem_Free(pTemp1);
    pTemp1 = NULL;
    Hal_Mem_Free(pTemp2);
    pTemp2                    = NULL;
    g_MsgGlobalCtrl.ResendFlg = false;
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Rep_Timeout(VOID* id)
{
    // sending report
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pSendingRep = NULL;
    UI_Button_Desc_t           *ButtonList  = NULL;

    pSendingRep = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSendingRep, 0, sizeof(UI_Normal_List_Only_Desc_t));

    if (g_MsgGlobalCtrl.ContactCnt != g_MsgGlobalCtrl.SuccessCnt)
    {
        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);
        pSendingRep->List.ListButtonCnt = 2;
        pSendingRep->List.Index         = 0;
        pSendingRep->List.ButtonList    = ButtonList;

        ButtonList[0].ButtonIndex = 0;
        ButtonList[0].TxtId       = LV_LANG_TXT_ID_NONE;

        ButtonList[0].BtnTxt = NULL;

        ButtonList[0].ReleaseFun = Sms_Send_To_Many_Sending_Rep_Sent;
        ButtonList[0].Valid      = true;

        ButtonList[1].ButtonIndex = 1;
        ButtonList[1].TxtId       = LV_LANG_TXT_ID_NONE;

        ButtonList[1].BtnTxt     = NULL;
        ButtonList[1].ReleaseFun = Sms_Send_To_Many_Sending_Rep_Failed;
        ButtonList[1].Valid      = true;
    }
    else
    {
        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t));
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t));
        pSendingRep->List.ListButtonCnt = 1;
        pSendingRep->List.Index         = 0;
        pSendingRep->List.ButtonList    = ButtonList;

        ButtonList[0].ButtonIndex = 0;
        ButtonList[0].TxtId       = LV_LANG_TXT_ID_NONE;

        ButtonList[0].BtnTxt = NULL;

        ButtonList[0].ReleaseFun = Sms_Send_To_Many_Sending_Rep_Sent;
        ButtonList[0].Valid      = true;
    }

    g_MsgGlobalCtrl.pChart = pSendingRep;

    pSendingRep->TitleBar.TxtId      = PHONE_TEXT_ID_SENDING_REP;
    pSendingRep->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSendingRep->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pSendingRep->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pSendingRep->BtnBar.ButtonR.Valid = true;

    pSendingRep->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pSendingRep->BtnBar.ButtonM.Valid = true;

    pSendingRep->KeyFunc = Sms_Sending_Rep_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Send_To_Many_Sending_Rep_Timeout_On_Create;
    FuncList.OnDestroy      = Sms_Send_To_Many_Sending_Rep_Destory;           // temp
    FuncList.OnSaveState    = Sms_Common_Save;                                // temp
    FuncList.OnRestoreState = Sms_Send_To_Many_Sending_Rep_Timeout_On_Create; // temp

    Nav_Back(ACT_ID_ANY);
    Nav_Back(ACT_ID_ANY);
    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_REPORT, &FuncList, (void *)pSendingRep);
} /* Sms_Send_To_Many_Sending_Rep_Timeout */

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Send_To_Many_Sending_Rep_Timeout_On_Create(VOID *pDesc)
{
    INT8                       *str    = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OUT_OF);
    INT8                       *str1   = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SENT_COLON);
    INT8                       *str2   = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_FAILED_COLON);
    INT8                       *pTemp  = Hal_Mem_Alloc(50);
    INT8                       *pTemp1 = Hal_Mem_Alloc(30);
    INT8                       *pTemp2 = Hal_Mem_Alloc(30);
    UINT16                     Temp;
    UI_Normal_List_Only_Desc_t *pSendingRep = pDesc;

    g_MsgGlobalCtrl.pChart = pSendingRep;

    Hal_Mem_Set(pTemp, 0, 50);
    Hal_Mem_Set(pTemp1, 0, 30);
    Hal_Mem_Set(pTemp2, 0, 30);

    if (g_MsgGlobalCtrl.ContactCnt != g_MsgGlobalCtrl.SuccessCnt)
    {
        strcpy(pTemp, str1);
        Temp = g_MsgGlobalCtrl.SuccessCnt;
        sprintf(pTemp1, "%d", Temp);
        strcat(pTemp, pTemp1);
        strcat(pTemp, str);
        Temp = g_MsgGlobalCtrl.ContactCnt;
        sprintf(pTemp2, "%d", Temp);
        strcat(pTemp, pTemp2);
        lv_label_set_text(lv_obj_get_child(pSendingRep->List.ButtonList[0].Button, NULL), pTemp);

        Hal_Mem_Set(pTemp, 0, 50);
        Hal_Mem_Set(pTemp1, 0, 30);
        Hal_Mem_Set(pTemp2, 0, 30);

        strcpy(pTemp, str2);
        Temp = g_MsgGlobalCtrl.ContactCnt - g_MsgGlobalCtrl.SuccessCnt;
        sprintf(pTemp1, "%d", Temp);
        strcat(pTemp, pTemp1);
        strcat(pTemp, str);
        Temp = g_MsgGlobalCtrl.ContactCnt;
        sprintf(pTemp2, "%d", Temp);
        strcat(pTemp, pTemp2);
        lv_label_set_text(lv_obj_get_child(pSendingRep->List.ButtonList[1].Button, NULL), pTemp);
    }
    else
    {
        strcpy(pTemp, str1);
        Temp = g_MsgGlobalCtrl.SuccessCnt;
        sprintf(pTemp1, "%d", Temp);
        strcat(pTemp, pTemp1);
        strcat(pTemp, str);
        Temp = g_MsgGlobalCtrl.ContactCnt;
        sprintf(pTemp2, "%d", Temp);
        strcat(pTemp, pTemp2);
        lv_label_set_text(lv_obj_get_child(pSendingRep->List.ButtonList[0].Button, NULL), pTemp);
    }

    Hal_Mem_Free(pTemp);
    pTemp = NULL;
    Hal_Mem_Free(pTemp1);
    pTemp1 = NULL;
    Hal_Mem_Free(pTemp2);
    pTemp2                  = NULL;
    g_MsgGlobalCtrl.SendCnt = 0;
} /* Sms_Send_To_Many_Sending_Rep_Timeout_On_Create */

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Send_To_Many_Sending_Rep_Destory(VOID *pDesc)
{
    Sms_Common_Free_ContactInfo();
    Sms_List_Only_Common_Destory(pDesc);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Sending_Rep_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Rep_Sent(lv_obj_t *pBtn,lv_event_t event)
{
    // select the sent content
    Nav_Func_List_t          FuncList;
    UI_Normal_Ta_Only_Desc_t *pSendRepSent = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pSendRepSent = (UI_Normal_Ta_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Ta_Only_Desc_t));
    Hal_Mem_Set(pSendRepSent, 0, sizeof(UI_Normal_Ta_Only_Desc_t));

    pSendRepSent->TitleBar.TxtId      = PHONE_TEXT_ID_RECIPIENTS;
    pSendRepSent->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pSendRepSent->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    pSendRepSent->ContTa.TaAlign      = LV_ALIGN_IN_LEFT_MID;
    pSendRepSent->ContTa.TaCursorHide = FALSE;
    pSendRepSent->ContTa.TaTxt        = NULL;

    pSendRepSent->ButtonBar.ButtonR.ButtonIndex = 0;
    pSendRepSent->ButtonBar.ButtonR.Valid       = true;
    pSendRepSent->ButtonBar.ButtonR.TxtId       = PHONE_TEXT_ID_BACK;
    pSendRepSent->KeyFunc                       = Sms_Create_Opt_Handle;// common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_Ta_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Sending_Rep_Sent_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_RECIPIENTS, &FuncList, (void *)pSendRepSent);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Sending_Rep_Sent_On_Create(VOID *pDesc)
{
    UINT32                   i             = 0;
    INT8                     str[]         = "\n";
    Msg_Contact_List_Info_t  *pContactInfo = NULL;
    UI_Normal_Ta_Only_Desc_t *pSendRepSent = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pSendRepSent           = g_MsgGlobalCtrl.pChart;

    if (0 != g_MsgGlobalCtrl.ContactCnt)
    {
        for (i = 0; i < g_MsgGlobalCtrl.ContactCnt; i++)
        {
            if (i)
            {
                pContactInfo = _lv_ll_get_next(g_MsgGlobalCtrl.pContactInfo, pContactInfo);
            }
            else
            {
                pContactInfo = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);
            }
            if (MSG_FAIL != pContactInfo->Result)
            {
                lv_textarea_add_text(pSendRepSent->ContTa.TextArea, pContactInfo->pContact);
                lv_textarea_add_text(pSendRepSent->ContTa.TextArea, str);
                lv_textarea_add_text(pSendRepSent->ContTa.TextArea, pContactInfo->pNum);
                lv_textarea_add_text(pSendRepSent->ContTa.TextArea, str);
            }
        }
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Rep_Failed(lv_obj_t *pBtn,lv_event_t event)
{
    // select the failed content
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pSendRepFail = NULL;
    UI_Button_Desc_t           *ButtonList   = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pSendRepFail = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSendRepFail, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    g_MsgGlobalCtrl.pChart = pSendRepFail;

    pSendRepFail->TitleBar.TxtId      = PHONE_TEXT_ID_FAILED_OPTIONS;
    pSendRepFail->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSendRepFail->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pSendRepFail->List.ListButtonCnt = 2;
    pSendRepFail->List.Index         = 0;
    pSendRepFail->List.ButtonList    = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_RESEND;
    ButtonList[0].ReleaseFun  = Sms_Send_To_Many_Sending_Rep_Failed_Resend;
    ButtonList[0].Valid       = true;

    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_VIEW;
    ButtonList[1].ReleaseFun  = Sms_Send_To_Many_Sending_Rep_Failed_View;
    ButtonList[1].Valid       = true;

    pSendRepFail->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pSendRepFail->BtnBar.ButtonR.Valid = true;

    pSendRepFail->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pSendRepFail->BtnBar.ButtonM.Valid = true;

    pSendRepFail->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_FAILED_OPTIONS, &FuncList, (void *)pSendRepFail);
} /* Sms_Send_To_Many_Sending_Rep_Failed */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Rep_Failed_Resend(lv_obj_t *pBtn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // select the failed resend function
    // create Message_Resending_Status chart
    Nav_Func_List_t          FuncList;
    INT8                     *str    = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_RESENDING);
    INT8                     *str1   = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_LEFT);
    INT8                     *pTemp  = Hal_Mem_Alloc(50);
    INT8                     *pTemp1 = Hal_Mem_Alloc(30);
    UINT16                   Temp2   = 0;
    UI_Normal_NoTitle_Desc_t *pResendingSts = NULL;
    ACTIVITY_ID TopAct = Nav_Get_Top();

    if (NULL == g_MsgGlobalCtrl.pCurrentSend)
    {
        pResendingSts = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
        Hal_Mem_Set(pResendingSts, 0, sizeof(UI_Normal_NoTitle_Desc_t));

        g_MsgGlobalCtrl.pChart = pResendingSts;

        g_MsgGlobalCtrl.ResendFlg = true;

        pResendingSts->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_MID;
        pResendingSts->ContenCont.ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
        pResendingSts->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
        pResendingSts->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_MID;

        pResendingSts->ContenCont.ContImg.Img      = IMG_PROGRESS_BAR;
        pResendingSts->ContenCont.ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
        pResendingSts->ContenCont.ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

        pResendingSts->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_STOP;
        pResendingSts->ButtonBar.ButtonR.Valid = true;

        pResendingSts->KeyFunc  = Sms_Send_To_Many_Sending_Rep_Failed_Resend_Handle;
        FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
        FuncList.OnHide         = NULL;
        FuncList.OnCreate       = Sms_Common_Create;
        FuncList.OnDestroy      = Sms_Common_Destory;  // temp
        FuncList.OnSaveState    = Sms_Common_Save;     // temp
        FuncList.OnRestoreState = Sms_Common_Restore;  // temp

        g_MsgGlobalCtrl.ResendCnt = g_MsgGlobalCtrl.ContactCnt - g_MsgGlobalCtrl.SuccessCnt;

        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_RESENDING_STATUS, &FuncList, (void *)pResendingSts);

        if (true != g_MsgGlobalCtrl.ResendFlg)
        {   // the first time
            g_MsgGlobalCtrl.pCurrentSend = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);
            while (NULL != g_MsgGlobalCtrl.pCurrentSend)
            {
                if (MSG_FAIL == g_MsgGlobalCtrl.pCurrentSend->Result)
                {
                    break;
                }
                g_MsgGlobalCtrl.pCurrentSend = _lv_ll_get_next(g_MsgGlobalCtrl.pContactInfo, g_MsgGlobalCtrl.pCurrentSend);
            }
            if (NULL != g_MsgGlobalCtrl.pCurrentSend)
            {
                Sms_Com_Send_Sms_To_List_Req();
            }
            else
            {
                if((ACT_ID_CALL_EMERGENCY_CALLING <= TopAct) && (ACT_ID_CALL_DTMF_INPUT >= TopAct))
                {
                    Nav_Forward(ACT_ID_MESSAGES_SENDING_STATUS, ACT_ID_MESSAGES, NULL, NULL);
                }
                else
                {
                    Sms_Send_To_Many_Sending_Sts_Stop(NULL);
                }
                return;
            }
            g_MsgGlobalCtrl.ResendFlg = true;
        }
    }
    else
    {
        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_RESENDING_STATUS, NULL, NULL);
    }
    Hal_Mem_Set(pTemp, 0, 50);
    Hal_Mem_Set(pTemp1, 0, 30);
    strcpy(pTemp, str);
    Temp2 = g_MsgGlobalCtrl.ResendCnt - g_MsgGlobalCtrl.SendCnt;
    sprintf(pTemp1, "%d", Temp2);
    strcat(pTemp, pTemp1);
    strcat(pTemp, str1);
    pResendingSts = g_MsgGlobalCtrl.pChart;
    lv_label_set_text(pResendingSts->ContenCont.ContLabel.Label, pTemp);
    Hal_Mem_Free(pTemp);
    pTemp = NULL;
    Hal_Mem_Free(pTemp1);
    pTemp1 = NULL;
} /* Sms_Send_To_Many_Sending_Rep_Failed_Resend */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Send_To_Many_Sending_Rep_Failed_Resend_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Sms_Send_To_Many_Sending_Sts_Stop(NULL);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_Many_Sending_Rep_Failed_View(lv_obj_t *pBtn,lv_event_t event)
{
    // select the failed view function
    Nav_Func_List_t          FuncList;
    UI_Normal_Ta_Only_Desc_t *pFailedView = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pFailedView = (UI_Normal_Ta_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Ta_Only_Desc_t));
    Hal_Mem_Set(pFailedView, 0, sizeof(UI_Normal_Ta_Only_Desc_t));

    pFailedView->TitleBar.TxtId      = PHONE_TEXT_ID_FAIL_RECIPIENTS;
    pFailedView->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pFailedView->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    pFailedView->ContTa.TaAlign      = LV_ALIGN_IN_LEFT_MID;
    pFailedView->ContTa.TaCursorHide = FALSE;
    pFailedView->ContTa.TaTxt        = NULL;

    pFailedView->ButtonBar.ButtonR.ButtonIndex = 0;
    pFailedView->ButtonBar.ButtonR.Valid       = true;
    pFailedView->ButtonBar.ButtonR.TxtId       = PHONE_TEXT_ID_BACK;
    pFailedView->KeyFunc                       = Sms_Create_Opt_Handle;// common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_Ta_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Sending_Rep_Failed_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_FAILED_RECIPIENTS, &FuncList, (void *)pFailedView);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Sending_Rep_Failed_On_Create(VOID *pDesc)
{
    UINT32                   i             = 0;
    INT8                     str[]         = "\n";
    Msg_Contact_List_Info_t  *pContactInfo = NULL;
    UI_Normal_Ta_Only_Desc_t *pFailedView  = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pFailedView            = g_MsgGlobalCtrl.pChart;

    if (0 != g_MsgGlobalCtrl.ContactCnt)
    {
        for (i = 0; i < g_MsgGlobalCtrl.ContactCnt; i++)
        {
            if (i)
            {
                pContactInfo = _lv_ll_get_next(g_MsgGlobalCtrl.pContactInfo, pContactInfo);
            }
            else
            {
                pContactInfo = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);
            }
            if (MSG_FAIL == pContactInfo->Result)
            {
                lv_textarea_add_text(pFailedView->ContTa.TextArea, pContactInfo->pContact);
                lv_textarea_add_text(pFailedView->ContTa.TextArea, str);
                lv_textarea_add_text(pFailedView->ContTa.TextArea, pContactInfo->pNum);
                lv_textarea_add_text(pFailedView->ContTa.TextArea, str);
            }
        }
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Send_To_List(lv_obj_t *pBtn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // send to list function,maybe create Messages_No_Distribution_List
    // or Messages_Distribution_List_Empty
    // or Messages_Distribution_Lists
    UINT32                       i = 0;
    Msg_Distribution_List_Info_t *pTemp  = NULL;
    UINT8                        *data   = Hal_Mem_Alloc(sizeof(NV_UI_Sms_Distribution_List_t));

    // get list name list from nvm
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DIST_LIST, 0, sizeof(NV_UI_Sms_Distribution_List_t), data);
    if (data[0])
    {
        g_MsgGlobalCtrl.pDisList = (Msg_Distribution_List_t *)Hal_Mem_Alloc(sizeof(Msg_Distribution_List_t));
        Hal_Mem_Set(g_MsgGlobalCtrl.pDisList, 0, sizeof(Msg_Distribution_List_t));
        g_MsgGlobalCtrl.pDisList->DistriCnt    = data[0];
        g_MsgGlobalCtrl.pDisList->pDisListInfo = (lv_ll_t *)Hal_Mem_Alloc(sizeof(lv_ll_t));
        Hal_Mem_Set(g_MsgGlobalCtrl.pDisList->pDisListInfo, 0, sizeof(lv_ll_t));
        _lv_ll_init(g_MsgGlobalCtrl.pDisList->pDisListInfo, sizeof(Msg_Distribution_List_Info_t));
        for (i = 0; i < g_MsgGlobalCtrl.pDisList->DistriCnt; i++)
        {
            if (i)
            {
                pTemp = _lv_ll_ins_tail(g_MsgGlobalCtrl.pDisList->pDisListInfo);
                Hal_Mem_Set(pTemp, 0, sizeof(Msg_Distribution_List_Info_t));
            }
            else
            {
                pTemp = _lv_ll_ins_head(g_MsgGlobalCtrl.pDisList->pDisListInfo);
                Hal_Mem_Set(pTemp, 0, sizeof(Msg_Distribution_List_Info_t));
            }
            pTemp->NvAddrOffset = NV_SMS_MAX_NAME_NUM * NV_SMS_MAX_LIST_NUM * i + 1;
            pTemp->pListName    = Hal_Mem_Alloc(NV_SMS_MAX_NAME_NUM);
            Hal_Mem_Set(pTemp->pListName, 0, NV_SMS_MAX_NAME_NUM);
            Hal_Mem_Copy(pTemp->pListName, &(data[NV_SMS_MAX_NAME_NUM * i + 1]), NV_SMS_MAX_NAME_NUM);
        }
    }
    Hal_Mem_Free(data);
    data = NULL;
    if (NULL == g_MsgGlobalCtrl.pDisList)
    {
        Sms_Create_Send_To_List_No_List(NULL);
    }
    else
    {
        if (0 == g_MsgGlobalCtrl.pDisList->DistriCnt)
        {
            Sms_Create_Send_To_List_No_List(NULL);
        }
        else
        {
            Sms_Send_To_List_Distribution_List(NULL);
        }
    }
} /* Sms_Create_Send_To_List */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Create_Send_To_List_No_List(lv_obj_t *pBtn)
{
    // create Messages_No_Distribution_List chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pNoList = NULL;
    CB_FUNC          callback = Sms_Create_Send_To_List_Empty_Timeout;

    pNoList = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pNoList, 0, sizeof(UI_Status_Desc_t));

    pNoList->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pNoList->ContLabel.TxtId      = PHONE_TEXT_ID_NO_LIST_AVAILABLE;
    pNoList->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pNoList->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pNoList->ContImg.Img      = LV_SYMBOL_WARNING;
    pNoList->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pNoList->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_NO_DISTRIBUTION_LIST, &FuncList, (void *)pNoList);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_NO_DISTRIBUTION_LIST);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Create_Send_To_List_Empty(lv_obj_t *pBtn)
{
    // create Messages_Distribution_List_Empty chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pListEmpty = NULL;
    CB_FUNC          callback    = Sms_Create_Send_To_List_Empty_Timeout;

    pListEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pListEmpty, 0, sizeof(UI_Status_Desc_t));

    pListEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pListEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_DISTRIBUTION_LIST_EMPTY;
    pListEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pListEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pListEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pListEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pListEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DISTRIBUTION_LIST_EMPTY, &FuncList, (void *)pListEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DISTRIBUTION_LIST_EMPTY);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in)
 * return  VOID
 */
VOID Sms_Create_Send_To_List_Empty_Timeout(VOID* id)
{
    // create Messages_Sending_Options chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_SENDING_OPTIONS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Send_To_List_Distribution_List(lv_obj_t *pBtn)
{
    // get the distribution list pointer(in g_MsgGlobalCtrl.pDisList->DistriCnt and g_MsgGlobalCtrl.pDisList->pDisListInfo) for send to list function

    // create Messages_Distribution_Lists
    UINT32                       i = 0;
    Nav_Func_List_t              FuncList;
    UI_Normal_List_Only_Desc_t   *pSendToDistriList = NULL;
    UI_Button_Desc_t             *ButtonList        = NULL;
    Msg_Distribution_List_Info_t *pDistriList       = NULL;

    pSendToDistriList = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSendToDistriList, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * g_MsgGlobalCtrl.pDisList->DistriCnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * g_MsgGlobalCtrl.pDisList->DistriCnt);

    g_MsgGlobalCtrl.pChart = pSendToDistriList;

    pSendToDistriList->TitleBar.TxtId      = PHONE_TEXT_ID_DISTRIBUTION_LISTS;
    pSendToDistriList->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSendToDistriList->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pSendToDistriList->List.ListButtonCnt = g_MsgGlobalCtrl.pDisList->DistriCnt;
    pSendToDistriList->List.Index         = 0;
    pSendToDistriList->List.ButtonList    = ButtonList;

    for (i = 0; i < g_MsgGlobalCtrl.pDisList->DistriCnt; i++)
    {
        if (i)
        {
            pDistriList = _lv_ll_get_next(g_MsgGlobalCtrl.pDisList->pDisListInfo, pDistriList);
        }
        else
        {
            pDistriList = _lv_ll_get_head(g_MsgGlobalCtrl.pDisList->pDisListInfo);
        }
        ButtonList[i].ButtonIndex = i;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pDistriList->pListName;
        ButtonList[i].ReleaseFun  = Sms_Send_To_List_Sim_Select;
        ButtonList[i].Valid       = true;
    }

    pSendToDistriList->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pSendToDistriList->BtnBar.ButtonR.Valid = true;

    if(g_MsgGlobalCtrl.pDisList->DistriCnt)
    {
        pSendToDistriList->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
        pSendToDistriList->BtnBar.ButtonM.Valid = true;
    }
    else
    {
        pSendToDistriList->BtnBar.ButtonM.Valid = false;
    }

    pSendToDistriList->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Send_To_List_Distribution_List_On_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory;                 // temp
    FuncList.OnSaveState    = Sms_Common_Save;                              // temp
    FuncList.OnRestoreState = Sms_Send_To_List_Distribution_List_On_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DISTRIBUTION_LISTS, &FuncList, (void *)pSendToDistriList);

    return(LV_RES_OK);
} /* Sms_Send_To_List_Distribution_List */

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Send_To_List_Distribution_List_On_Create(VOID *pDesc)
{
    UINT32                       i                  = 0;
    UI_Normal_List_Only_Desc_t   *pSendToDistriList = NULL;
    Msg_Distribution_List_Info_t *pDistriList       = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pSendToDistriList      = g_MsgGlobalCtrl.pChart;

    for (i = 0; i < g_MsgGlobalCtrl.pDisList->DistriCnt; i++)
    {
        if (i)
        {
            pDistriList = _lv_ll_get_next(g_MsgGlobalCtrl.pDisList->pDisListInfo, pDistriList);
        }
        else
        {
            pDistriList = _lv_ll_get_head(g_MsgGlobalCtrl.pDisList->pDisListInfo);
        }
        pSendToDistriList->List.ButtonList[i].Button->user_data.user_num = pDistriList->NvAddrOffset;
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_List_Sim_Select(lv_obj_t *pBtn,lv_event_t event)
{
    // create the Messages_Sim_Selection chart
    UINT32                                i       = 0;
    INT8                                  str     = '\0';
    INT8                                  *pTemp  = NULL;
    Nav_Func_List_t                       FuncList;
    UI_Normal_List_Only_Desc_t            *pSendToMany = NULL;
    UI_Button_Desc_t                      *ButtonList  = NULL;
    NV_UI_Sms_Distribution_Contact_Name_t *data        = NULL;
    Msg_Contact_List_Info_t               *pNode1      = NULL;
    SMS_SIM_STATUS                        SimStatus    = SMS_NO_SIM_PRESENT;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pTemp = lv_label_get_text(lv_obj_get_child(pBtn, NULL));

    Hal_Mem_Free(g_MsgGlobalCtrl.pDistriListName);
    g_MsgGlobalCtrl.pDistriListName = NULL;
    g_MsgGlobalCtrl.pDistriListName = Hal_Mem_Alloc(NV_SMS_MAX_NAME_NUM);
    Hal_Mem_Set(g_MsgGlobalCtrl.pDistriListName, 0, NV_SMS_MAX_NAME_NUM);
    strcpy(g_MsgGlobalCtrl.pDistriListName, pTemp);

    // get list from nvm to g_MsgGlobalCtrl.ContactCnt and g_MsgGlobalCtrl.pContactInfo with freenum
    data = (NV_UI_Sms_Distribution_Contact_Name_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Distribution_Contact_Name_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Distribution_Contact_Name_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DIST_CONT_LIST, (UINT32)pBtn->user_data.user_num, sizeof(NV_UI_Sms_Distribution_Contact_Name_t), (UINT8 *)data);
    Sms_Common_Free_ContactInfo();
    g_MsgGlobalCtrl.pContactInfo = (lv_ll_t *)Hal_Mem_Alloc(sizeof(lv_ll_t));
    Hal_Mem_Set(g_MsgGlobalCtrl.pContactInfo, 0, sizeof(lv_ll_t));
    _lv_ll_init(g_MsgGlobalCtrl.pContactInfo, sizeof(Msg_Contact_List_Info_t));
    for (i = 0; false != strcmp(data->ContactName[i], &str); i++)
    {
        if (NV_SMS_MAX_LIST_NUM == i)
        {
            break;
        }
        else
        {
            g_MsgGlobalCtrl.ContactCnt++;
        }
        if (i)
        {
            pNode1 = _lv_ll_ins_tail(g_MsgGlobalCtrl.pContactInfo);
            Hal_Mem_Set(pNode1, 0, sizeof(Msg_Contact_List_Info_t));
        }
        else
        {
            pNode1 = _lv_ll_ins_head(g_MsgGlobalCtrl.pContactInfo);
            Hal_Mem_Set(pNode1, 0, sizeof(Msg_Contact_List_Info_t));
        }
        pNode1->Index    = i;
        pNode1->pContact = Hal_Mem_Alloc(NV_SMS_MAX_NAME_NUM);
        Hal_Mem_Set(pNode1->pContact, 0, NV_SMS_MAX_NAME_NUM);
        Hal_Mem_Copy(pNode1->pContact, data->ContactName[i], NV_SMS_MAX_NAME_NUM);
        pNode1->pNum = Contacts_Get_Contact_Number_Req(pNode1->pContact);
        if (NULL == pNode1->pNum)
        {
            _lv_ll_remove(g_MsgGlobalCtrl.pContactInfo, pNode1);
            Hal_Mem_Free(pNode1->pContact);
            pNode1->pContact = NULL;
            Hal_Mem_Free(pNode1);
            pNode1 = NULL;
            g_MsgGlobalCtrl.ContactCnt--;
        }
    }
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Distribution_Contact_Name_t));
    for (i = 0; i < g_MsgGlobalCtrl.ContactCnt; i++)
    {
        if (i)
        {
            pNode1 = _lv_ll_get_tail(g_MsgGlobalCtrl.pContactInfo);
        }
        else
        {
            pNode1 = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);
        }
        Hal_Mem_Copy(data->ContactName[i], pNode1->pContact, NV_SMS_MAX_NAME_NUM);
    }
    UI_NV_Write_Req(NV_SECTION_UI_SMS_DIST_CONT_LIST, (UINT32)pBtn->user_data.user_num, sizeof(NV_UI_Sms_Distribution_Contact_Name_t), (UINT8 *)data);
    UI_NV_Write_Req(NV_SECTION_UI_SMS_DIST_CONT_LIST, 0, 1, (UINT8 *)&g_MsgGlobalCtrl.ContactCnt);
    if (0 == g_MsgGlobalCtrl.ContactCnt)
    {
        Sms_Common_Free_ContactInfo();
        Sms_Create_Send_To_List_Empty(NULL);
        return;
    }
    Hal_Mem_Free(data);
    data        = NULL;
    pSendToMany = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSendToMany, 0, sizeof(UI_Normal_List_Only_Desc_t));

    g_MsgGlobalCtrl.pChart       = pSendToMany;
    g_MsgGlobalCtrl.pCurrentSend = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);

    pSendToMany->TitleBar.TxtId      = PHONE_TEXT_ID_SIM_SEL;
    pSendToMany->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSendToMany->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    SimStatus = Sms_Get_Sim_Status();
    if (SMS_SIM1_PRESENT == (SimStatus & SMS_SIM1_PRESENT))
    {
        pSendToMany->List.ListButtonCnt++;
    }
    if (SMS_SIM2_PRESENT == (SimStatus & SMS_SIM2_PRESENT))
    {
        pSendToMany->List.ListButtonCnt++;
    }
    if (pSendToMany->List.ListButtonCnt)
    {
        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * pSendToMany->List.ListButtonCnt);
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * pSendToMany->List.ListButtonCnt);
        pSendToMany->List.Index      = 0;
        pSendToMany->List.ButtonList = ButtonList;

        if (SMS_BOTH_SIM_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_List_Distribution_Cnf;

            ButtonList[1].ButtonIndex = 1;
            ButtonList[1].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[1].SymbolId1   = SYMBOL_SIM2;
            ButtonList[1].Valid       = true;
            ButtonList[1].ReleaseFun  = Sms_Send_To_List_Distribution_Cnf;
        }
        else if (SMS_SIM1_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM1;
            ButtonList[0].SymbolId1   = SYMBOL_SIM1;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_List_Distribution_Cnf;
        }
        else if (SMS_SIM2_PRESENT == SimStatus)
        {
            ButtonList[0].ButtonIndex = 0;
            ButtonList[0].TxtId       = PHONE_TEXT_ID_SIM2;
            ButtonList[0].SymbolId1   = SYMBOL_SIM2;
            ButtonList[0].Valid       = true;
            ButtonList[0].ReleaseFun  = Sms_Send_To_List_Distribution_Cnf;
        }
    }

    pSendToMany->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pSendToMany->BtnBar.ButtonR.Valid = true;

    if(SimStatus != SMS_NO_SIM_PRESENT)
    {
        pSendToMany->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
        pSendToMany->BtnBar.ButtonM.Valid = true;
    }
    else
    {
        pSendToMany->BtnBar.ButtonM.Valid = false;
    }

    pSendToMany->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Create_Send_To_Many_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory;   // temp
    FuncList.OnSaveState    = Sms_Common_Save;                // temp
    FuncList.OnRestoreState = Sms_Create_Send_To_Many_Create; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SIM_SELECTION, &FuncList, (void *)pSendToMany);
} /* Sms_Send_To_List_Sim_Select */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Send_To_List_Distribution_Cnf(lv_obj_t *pBtn,lv_event_t event)
{
    // Sim selection call back function
    // create Messages_Distribution_Confirm chart

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    g_MsgGlobalCtrl.CurrSimId = (MMI_MODEM_SIM_ID)pBtn->user_data.user_num;
    Nav_Func_List_t          FuncList;
    INT8                     *str        = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEND_TO_LIST_Q);
    INT8                     *pTemp1     = Hal_Mem_Alloc(30);
    INT8                     *pTemp      = Hal_Mem_Alloc(100);
    UI_Normal_NoTitle_Desc_t *pDistriCnf = NULL;

    pDistriCnf = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDistriCnf, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDistriCnf;

    pDistriCnf->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDistriCnf->ContenCont.ContLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    pDistriCnf->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDistriCnf->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDistriCnf->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDistriCnf->ButtonBar.ButtonR.Valid = true;

    pDistriCnf->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDistriCnf->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDistriCnf->ButtonBar.ButtonM.Valid      = true;

    pDistriCnf->KeyFunc = Sms_Send_To_List_Distribution_Cnf_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DISTRIBUTION_CONFIRM, &FuncList, (void *)pDistriCnf);

    Hal_Mem_Set(pTemp, 0, 100);
    Hal_Mem_Set(pTemp1, 0, 30);
    sprintf(pTemp1, "%s", g_MsgGlobalCtrl.pDistriListName);
    strcpy(pTemp, str);
    strcat(pTemp, pTemp1);

    lv_label_set_text(pDistriCnf->ContenCont.ContLabel.Label, pTemp);
    Hal_Mem_Free(pTemp);
    pTemp = NULL;
    Hal_Mem_Free(pTemp1);
    pTemp1 = NULL;
} /* Sms_Send_To_List_Distribution_Cnf */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Send_To_List_Distribution_Cnf_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Send_To_List_Distribution_Cnf_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Send_To_List_Distribution_Cnf_OK(lv_obj_t *pBtn)
{
    Sms_Send_To_Many_Sending_Sts();
    g_MsgGlobalCtrl.pCurrentSend = _lv_ll_get_head(g_MsgGlobalCtrl.pContactInfo);
    if (NULL != g_MsgGlobalCtrl.pCurrentSend)
    {
        Sms_Com_Send_Sms_To_List_Req();
    }
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Insert_Options(lv_obj_t *pBtn,lv_event_t event)
{
    // insert options call back function
    UINT8                      Temp;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pInsertOpt = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pInsertOpt = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pInsertOpt, 0, sizeof(UI_Normal_List_Only_Desc_t));

    if (MSG_DICTIONARY_ENB == g_MsgGlobalCtrl.DictionaryFlg)
    {
        Temp = 3;
    }
    else
    {
        Temp = 2;
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Temp);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Temp);

    g_MsgGlobalCtrl.pChart = pInsertOpt;

    pInsertOpt->TitleBar.TxtId      = PHONE_TEXT_ID_INSERT_OPT;
    pInsertOpt->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pInsertOpt->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pInsertOpt->List.ListButtonCnt = Temp;
    pInsertOpt->List.Index         = 0;
    pInsertOpt->List.ButtonList    = ButtonList;

    if (MSG_DICTIONARY_ENB == g_MsgGlobalCtrl.DictionaryFlg)
    {
        ButtonList[0].ButtonIndex = 0;
        ButtonList[0].TxtId       = PHONE_TEXT_ID_INSERT_WORD;
        ButtonList[0].ReleaseFun  = Sms_Create_Insert_Option_Word;
        ButtonList[0].Valid       = true;

        ButtonList[1].ButtonIndex = 1;
        ButtonList[1].TxtId       = PHONE_TEXT_ID_INSERT_NUM;
        ButtonList[1].ReleaseFun  = Sms_Create_Insert_Option_Num;
        ButtonList[1].Valid       = true;

        ButtonList[2].ButtonIndex = 2;
        ButtonList[2].TxtId       = PHONE_TEXT_ID_INSERT_SYM;
        ButtonList[2].ReleaseFun  = Sms_Create_Insert_Option_Symbol;
        ButtonList[2].Valid       = true;
    }
    else
    {
        ButtonList[0].ButtonIndex = 0;
        ButtonList[0].TxtId       = PHONE_TEXT_ID_INSERT_NUM;
        ButtonList[0].ReleaseFun  = Sms_Create_Insert_Option_Num;
        ButtonList[0].Valid       = true;

        ButtonList[1].ButtonIndex = 1;
        ButtonList[1].TxtId       = PHONE_TEXT_ID_INSERT_SYM;
        ButtonList[1].ReleaseFun  = Sms_Create_Insert_Option_Symbol;
        ButtonList[1].Valid       = true;
    }
    pInsertOpt->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pInsertOpt->BtnBar.ButtonR.Valid = true;

    pInsertOpt->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pInsertOpt->BtnBar.ButtonM.Valid = true;

    pInsertOpt->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INSERT_OPTIONS, &FuncList, (void *)pInsertOpt);
} /* Sms_Create_Insert_Options */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Insert_Option_Num(lv_obj_t *pBtn,lv_event_t event)
{
    // insert number call back function
    // create Messages_Insert_Number chart

    Nav_Func_List_t                   FuncList;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pInsertNum = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pInsertNum = (UI_Normal_NoTitle_Label_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));
    Hal_Mem_Set(pInsertNum, 0, sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));

    g_MsgGlobalCtrl.pChart = pInsertNum;

    pInsertNum->ContLabelTl.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;
    pInsertNum->ContLabelTl.TxtId       = LV_LANG_TXT_ID_NONE;
    pInsertNum->ContLabelTl.SymbolAlign = LV_LABEL_ALIGN_CENTER;
    pInsertNum->ContLabelTr.LabelAlign  = LV_ALIGN_IN_TOP_RIGHT;
    pInsertNum->ContLabelTr.TxtId       = LV_LANG_TXT_ID_NONE;
    pInsertNum->ContLabelTr.TxtAlign    = LV_LABEL_ALIGN_CENTER;
    pInsertNum->ContLabel.LabelAlign    = LV_ALIGN_IN_TOP_MID;
    pInsertNum->ContLabel.TxtId         = PHONE_TEXT_ID_INSERT_NUM;
    pInsertNum->ContLabel.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    pInsertNum->ContTa.TaCursorHide     = FALSE;
    pInsertNum->ContTa.TaTxt            = NULL;

    pInsertNum->ButtonCont.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pInsertNum->ButtonCont.ButtonL.Valid = true;

    pInsertNum->ButtonCont.ButtonM.TxtId = PHONE_TEXT_ID_SEARCH;
    pInsertNum->ButtonCont.ButtonM.Valid = true;

    pInsertNum->ButtonCont.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    pInsertNum->ButtonCont.ButtonR.Valid = true;

    pInsertNum->KeyFunc = Sms_Create_Insert_Num_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Label_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Insert_Num_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INSERT_NUMBER, &FuncList, (void *)pInsertNum);
} /* Sms_Create_Insert_Option_Num */

/**
 * Process UI input char number event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Insert_Num_Input_char_Process(UINT8 Len)
{
    UINT32                            i = 0;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    INT8                              *pTemp     = NULL;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = g_MsgGlobalCtrl.pChart;

    pTemp = lv_label_get_text(pPhoneNum->ContLabelTr.Label);
    i     = atoi(pTemp);
    sprintf(Temp, "%d", (i - Len));
    lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Insert_Num_On_Create(VOID *pDesc)
{
    INT8                              Temp1[MSG_TEXT_INPUT_MAX_LEN];

    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pPhoneNum              = g_MsgGlobalCtrl.pChart;

    lv_textarea_set_accepted_chars(pPhoneNum->ContTa.TextArea, g_AcceptInputNum);
    lv_textarea_set_max_length(pPhoneNum->ContTa.TextArea, MSG_INPUT_PHONE_NUM_MAX_LEN);

    sprintf(Temp1, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN);
    lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp1);
    Ime_Set_GetCharLen_Func(Sms_Insert_Num_Input_char_Process);
    Ime_Set_Mode(LV_IME_MODE_NUM);
}

/**
 * sub-module entry
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Create_Insert_Num_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8                             Result = 0;
    UINT32                            i      = 0;
    INT8                              *pTemp;
    INT8                              *pTemp1;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    UI_Normal_NoTitle_Label_Ta_Desc_t *pPhoneNum = g_MsgGlobalCtrl.pChart;    // temp

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        switch (key_val)
        {
        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);            // temp
            i     = strlen(pTemp);
            if (i < MSG_INPUT_PHONE_NUM_MAX_LEN)
            {
                sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN - i - 1);
            }
            else
            {
                sprintf(Temp, "%d", 0);
                Result = 1;
            }
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_OK));
            break;

        case KEY_SOFTRIGHT:
            lv_textarea_del_char(obj);
            pTemp = (INT8 *)lv_textarea_get_text(obj);
            i     = strlen(pTemp);
            if (0 == i)
            {            // clear all
                lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEARCH));
            }
            sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN - i);
            lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
            Result = 1;
            break;

        case KEY_SOFTLEFT:
            Nav_Back(ACT_ID_ANY);
            Result = 1;
            break;

        case KEY_OK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);        // temp
            i     = strlen(pTemp);
            if (i)
            {            // ok
                pTemp1 = Hal_Mem_Alloc(MSG_INPUT_WORD_MAX_LEN + 1);
                Hal_Mem_Set(pTemp1, 0, MSG_INPUT_WORD_MAX_LEN + 1);
                if (NULL != g_MsgGlobalCtrl.pSmsText)
                {
                    pTemp1 = strcat(pTemp1, g_MsgGlobalCtrl.pSmsText);
                }
                pTemp1 = strcat(pTemp1, pTemp);
                Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
                g_MsgGlobalCtrl.pSmsText = pTemp1;

                Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
            }
            else
            {            // search
                g_MsgGlobalCtrl.SelContactType = IF_CONTACTS_SMS_SEL_ONE_CONTACT;
                g_MsgGlobalCtrl.InsertNumFlg   = true;
                Contacts_Select_Contact_Req(IF_CONTACTS_SMS_SEL_ONE_CONTACT);
            }
            Result = 1;
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            Result = 1;
            break;

        default:
            break;
        } /* switch */
    }
    else if (KEY_LONGPRESS == key_sta)
    {    // clear all
        if (KEY_SOFTRIGHT == key_val)
        {
            lv_textarea_set_text(obj, "");
            sprintf(Temp, "%d", MSG_INPUT_PHONE_NUM_MAX_LEN);
            lv_label_set_text(pPhoneNum->ContLabelTr.Label, Temp);
            lv_label_set_text((lv_obj_t *)pPhoneNum->ButtonCont.ButtonM.Button->child_ll.head, UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SEARCH));
        }
    }
    return(Result);   // temp
} /* Sms_Create_Insert_Num_Handle */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Insert_Option_Word(lv_obj_t *pBtn,lv_event_t event)
{
    // insert word call back function
    // create Messages_Insert_Word chart

    Nav_Func_List_t                   FuncList;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pInsertWord = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pInsertWord = (UI_Normal_NoTitle_Label_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));
    Hal_Mem_Set(pInsertWord, 0, sizeof(UI_Normal_NoTitle_Label_Ta_Desc_t));

    g_MsgGlobalCtrl.pChart = pInsertWord;

    pInsertWord->ContLabelTl.LabelAlign  = LV_ALIGN_IN_TOP_LEFT;
    pInsertWord->ContLabelTl.TxtId       = LV_LANG_TXT_ID_NONE;
    pInsertWord->ContLabelTl.SymbolAlign = LV_LABEL_ALIGN_CENTER;
    pInsertWord->ContLabelTr.LabelAlign  = LV_ALIGN_IN_TOP_RIGHT;
    pInsertWord->ContLabelTr.TxtId       = LV_LANG_TXT_ID_NONE;
    pInsertWord->ContLabelTr.TxtAlign    = LV_LABEL_ALIGN_CENTER;
    pInsertWord->ContLabel.LabelAlign    = LV_ALIGN_IN_TOP_MID;
    pInsertWord->ContLabel.TxtId         = PHONE_TEXT_ID_INSERT_WORD;
    pInsertWord->ContLabel.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    pInsertWord->ContTa.TaCursorHide     = FALSE;
    pInsertWord->ContTa.TaTxt            = NULL;

    pInsertWord->ButtonCont.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pInsertWord->ButtonCont.ButtonL.Valid = true;

    pInsertWord->ButtonCont.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    pInsertWord->ButtonCont.ButtonM.Valid = true;

    pInsertWord->ButtonCont.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
    pInsertWord->ButtonCont.ButtonR.Valid = true;

    pInsertWord->KeyFunc = Sms_Create_Insert_Word_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Label_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Insert_Word_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INSERT_WORD, &FuncList, (void *)pInsertWord);
} /* Sms_Create_Insert_Option_Word */

/**
 * Process UI input char number event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Insert_Word_Input_char_Process(UINT8 Len)
{
    UINT32                            i = 0;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    INT8                              *pTemp       = NULL;
    UI_Normal_NoTitle_Label_Ta_Desc_t *pInsertWord = g_MsgGlobalCtrl.pChart;

    pTemp = lv_label_get_text(pInsertWord->ContLabelTr.Label);
    i     = atoi(pTemp);
    sprintf(Temp, "%d", (i - Len));
    lv_label_set_text(pInsertWord->ContLabelTr.Label, Temp);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Insert_Word_On_Create(VOID *pDesc)
{
    INT8                              Temp1[MSG_TEXT_INPUT_MAX_LEN];

    UI_Normal_NoTitle_Label_Ta_Desc_t *pInsertWord = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pInsertWord            = g_MsgGlobalCtrl.pChart;

    lv_textarea_set_max_length(pInsertWord->ContTa.TextArea, MSG_INSERT_WORD_MAX_LEN);

    sprintf(Temp1, "%d", MSG_INSERT_WORD_MAX_LEN);
    lv_label_set_text(pInsertWord->ContLabelTr.Label, Temp1);
    Ime_Set_GetCharLen_Func(Sms_Insert_Word_Input_char_Process);
}

/**
 * sub-module entry
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Create_Insert_Word_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    // Insert words Ta call back function
    UINT8                             Result = 0;
    UINT32                            i      = 0;
    INT8                              *pTemp;
    INT8                              *pTemp1;
    INT8                              Temp[MSG_TEXT_INPUT_MAX_LEN];
    UI_Normal_NoTitle_Label_Ta_Desc_t *pInsertWord = g_MsgGlobalCtrl.pChart;    // temp

    // Insert number Ta call back function
    // refresh search btn

    if (KEY_RELEASED == key_sta)
    {
        switch (key_val)
        {
        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);            // temp
            i     = strlen(pTemp);
            if (i < MSG_INSERT_WORD_MAX_LEN)
            {
                sprintf(Temp, "%d", MSG_INSERT_WORD_MAX_LEN - i - 1);
            }
            else
            {
                sprintf(Temp, "%d", 0);
                Result = 1;
            }
            lv_label_set_text(pInsertWord->ContLabelTr.Label, Temp);
            break;

        case KEY_SOFTRIGHT:
            lv_textarea_del_char(obj);
            pTemp = (INT8 *)lv_textarea_get_text(obj);
            i     = strlen(pTemp);
            sprintf(Temp, "%d", MSG_INSERT_WORD_MAX_LEN - i);
            lv_label_set_text(pInsertWord->ContLabelTr.Label, Temp);
            Result = 1;
            break;

        case KEY_SOFTLEFT:
            Nav_Back(ACT_ID_ANY);
            Result = 1;
            break;

        case KEY_OK:
            pTemp = (INT8 *)lv_textarea_get_text(obj);        // temp
            i     = strlen(pTemp);
            if (i)
            {            // ok
                pTemp1 = Hal_Mem_Alloc(MSG_INPUT_WORD_MAX_LEN + 1);
                Hal_Mem_Set(pTemp1, 0, MSG_INPUT_WORD_MAX_LEN + 1);
                if (NULL != g_MsgGlobalCtrl.pSmsText)
                {
                    pTemp1 = strcat(pTemp1, g_MsgGlobalCtrl.pSmsText);
                }
                pTemp1 = strcat(pTemp1, pTemp);
                Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
                g_MsgGlobalCtrl.pSmsText = pTemp1;
            }

            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
            Result = 1;
            break;

        case KEY_END:
            Nav_Home(ACT_ID_ANY);
            Result = 1;
            break;

        default:
            break;
        } /* switch */
    }
    else if (KEY_LONGPRESS == key_sta)
    {    // clear all
        if (KEY_SOFTRIGHT == key_val)
        {
            lv_textarea_set_text(obj, "");
            sprintf(Temp, "%d", MSG_INSERT_WORD_MAX_LEN);
            lv_label_set_text(pInsertWord->ContLabelTr.Label, Temp);
        }
    }
    return(Result);   // temp
} /* Sms_Create_Insert_Word_Handle */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Insert_Option_Symbol(lv_obj_t *pBtn,lv_event_t event)
{
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // insert symbol call back function
    // create Messages_Insert_Symbol chart
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Create_Insert_Symbol_Use(lv_obj_t *pBtn)
{
    // insert symbol button matrix use call back function
    // go to Sms_Create
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Create_Insert_Symbol_Back(lv_obj_t *pBtn)
{
    // Insert symbol back to Messages_Insert_Options chart
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pLabel,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Save_Messages(lv_obj_t *pLabel,lv_event_t event)
{
    // create Messages_Save_Messages chart
    Nav_Func_List_t    FuncList;
    UI_Status_Desc_t   *pSaveMessages = NULL;
    UINT32             i              = 0;
    INT8               str            = '\0';
    NV_UI_Sms_Drafts_t *data          = NULL;
    CB_FUNC            callback       = Sms_Create_Save_Messages_Timeout;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pSaveMessages = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pSaveMessages, 0, sizeof(UI_Status_Desc_t));

    pSaveMessages->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pSaveMessages->ContLabel.TxtId      = PHONE_TEXT_ID_SAVE_SMS;
    pSaveMessages->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pSaveMessages->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pSaveMessages->ContImg.Img      = SYMBOL_CHECKED;
    pSaveMessages->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pSaveMessages->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SAVE_MESSAGES, &FuncList, (void *)pSaveMessages);
    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);

    for (i = 0; false != strcmp((INT8 *)data->Drafts[i].DraftContent, &str); i++)
    {
        if (NV_SMS_MAX_DRAFTS_NUM == i)
        {
            break;
        }
    }
    if (NV_SMS_MAX_DRAFTS_NUM == i)
    {
        Hal_Mem_Set(data->Drafts[0].DraftContent, 0, NV_SMS_MAX_INPUT_NUM);
        if (NULL != g_MsgGlobalCtrl.pSmsText)
        {
            strcpy(data->Drafts[0].DraftContent, g_MsgGlobalCtrl.pSmsText);
        }
    }
    else
    {
        if (NULL != g_MsgGlobalCtrl.pSmsText)
        {
            strcpy(data->Drafts[i].DraftContent, g_MsgGlobalCtrl.pSmsText);
        }
    }
    if (NULL != g_MsgGlobalCtrl.pSmsText)
    {
        UI_NV_Write_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    }
    Hal_Mem_Free(data);
    data = NULL;
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_SAVE_MESSAGES);
} /* Sms_Create_Save_Messages */

/**
 * sub-module entry
 * param (in)
 * return  VOID
 */
VOID Sms_Create_Save_Messages_Timeout(VOID* id)
{
    // create Messages_Create_Messages chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Clear_Text(lv_obj_t *pBtn,lv_event_t event)
{
    // delete sms Ta and go to Sms_Create
    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);// temp
    g_MsgGlobalCtrl.pSmsText = NULL;
    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Exit_Editor(lv_obj_t *pBtn,lv_event_t event)
{
    // save sms Ta to drafts box and go to Sms_Main
    UINT32             i     = 0;
    INT8               str[] = "\0";
    NV_UI_Sms_Drafts_t *data = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);

    for (i = 0; false != strcmp((INT8 *)data->Drafts[i].DraftContent, str); i++)
    {
        if (NV_SMS_MAX_DRAFTS_NUM == i)
        {
            break;
        }
    }
    if (NV_SMS_MAX_DRAFTS_NUM == i)
    {
        Hal_Mem_Set(data->Drafts[0].DraftContent, 0, NV_SMS_MAX_INPUT_NUM);
        if (NULL != g_MsgGlobalCtrl.pSmsText)
        {
            strcpy(data->Drafts[0].DraftContent, g_MsgGlobalCtrl.pSmsText);
        }
    }
    else
    {
        if (NULL != g_MsgGlobalCtrl.pSmsText)
        {
            strcpy(data->Drafts[i].DraftContent, g_MsgGlobalCtrl.pSmsText);
        }
    }
    if (NULL != g_MsgGlobalCtrl.pSmsText)
    {
        UI_NV_Write_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    }
    Hal_Mem_Free(data);
    data = NULL;
    Nav_Home(ACT_ID_ANY);// temp
} /* Sms_Create_Exit_Editor */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Dictionary(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Dictionary chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDictionary = NULL;
    UI_Button_Desc_t           *ButtonList  = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDictionary = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDictionary, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    g_MsgGlobalCtrl.pChart = pDictionary;

    pDictionary->TitleBar.TxtId      = PHONE_TEXT_ID_DICTIONARY;
    pDictionary->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDictionary->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pDictionary->List.ListButtonCnt = 2;
    pDictionary->List.Index         = 0;
    pDictionary->List.ButtonList    = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_DICTIONARY_ON;
    ButtonList[0].ReleaseFun  = Sms_Create_Dictionary_Sts;
    ButtonList[0].Valid       = true;

    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_DICTIONARY_OFF;
    ButtonList[1].ReleaseFun  = Sms_Create_Dictionary_Sts;
    ButtonList[1].Valid       = true;

    pDictionary->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDictionary->BtnBar.ButtonR.Valid = true;

    pDictionary->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    pDictionary->BtnBar.ButtonM.Valid = true;

    pDictionary->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DICTIONARY, &FuncList, (void *)pDictionary);
    pDictionary->List.ButtonList[0].Button->user_data.user_num = MSG_DICTIONARY_ENB;
    pDictionary->List.ButtonList[1].Button->user_data.user_num = MSG_DICTIONARY_SWITCH_OFF;
} /* Sms_Create_Dictionary */

/**
 * sub-module entry
 * param (in) lv_obj_t *pLabel,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Dictionary_Sts(lv_obj_t *pLabel,lv_event_t event)
{
    // Dictionary list call back function
    // create Messages_Dictionary_Status chart

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    g_MsgGlobalCtrl.DictionaryFlg = (MSG_DICTIONARY_ENABLE_TYPE)pLabel->user_data.user_num;
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDictionarySts = NULL;
    NV_UI_Sms_t      *data           = (NV_UI_Sms_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_t));
    CB_FUNC          callback        = Sms_Create_Dictionary_Sts_Timeout;

    pDictionarySts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDictionarySts, 0, sizeof(UI_Status_Desc_t));

    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS, 0, sizeof(NV_UI_Sms_t), (UINT8 *)data);
    data->DictionaryFlg = g_MsgGlobalCtrl.DictionaryFlg;
    UI_NV_Write_Req(NV_SECTION_UI_SMS, 0, sizeof(NV_UI_Sms_t), (UINT8 *)data);

    pDictionarySts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDictionarySts->ContLabel.SymbolId   = SYMBOL_CHECKED;  // temp
    if (MSG_DICTIONARY_ENB == g_MsgGlobalCtrl.DictionaryFlg)
    {
        IME_Config_Req(MESSAGE_IME_DICTIONARY_ENABLE);
        pDictionarySts->ContLabel.TxtId = PHONE_TEXT_ID_DICTIONARY_ON;
    }
    else
    {
        IME_Config_Req(MESSAGE_IME_DICTIONARY_OFF);
        pDictionarySts->ContLabel.TxtId = PHONE_TEXT_ID_DICTIONARY_OFF;
    }
    Hal_Mem_Free(data);
    data                               = NULL;
    pDictionarySts->ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDictionarySts->ContLabelAlign     = LV_ALIGN_IN_TOP_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DICTIONARY_STATUS, &FuncList, (void *)pDictionarySts);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DICTIONARY_STATUS);
} /* Sms_Create_Dictionary_Sts */

/**
 * sub-module entry
 * param (in)
 * return  VOID
 */
VOID Sms_Create_Dictionary_Sts_Timeout(VOID* id)
{
    // back to Messages_Create_Message_Opt. chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_CREATE_MESSAGE_OPT, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Matches_Body(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Matches_Body chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pMatchesBody = NULL;
    UI_Button_Desc_t           *ButtonList   = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pMatchesBody = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pMatchesBody, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2); // temp
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);                     // temp

    g_MsgGlobalCtrl.pChart = pMatchesBody;

    pMatchesBody->TitleBar.TxtId      = PHONE_TEXT_ID_MATCHES;
    pMatchesBody->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pMatchesBody->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pMatchesBody->List.ListButtonCnt = 2;    // temp
    pMatchesBody->List.Index         = 0;
    pMatchesBody->List.ButtonList    = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = LV_LANG_TXT_ID_NONE;
    ButtonList[0].ReleaseFun  = Sms_Create_Matches_Body_OK;
    ButtonList[0].Valid       = true;

    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = LV_LANG_TXT_ID_NONE;
    ButtonList[1].ReleaseFun  = Sms_Create_Matches_Body_OK;
    ButtonList[1].Valid       = true;

    pMatchesBody->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pMatchesBody->BtnBar.ButtonR.Valid = true;

    pMatchesBody->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    pMatchesBody->BtnBar.ButtonM.Valid = true;

    pMatchesBody->KeyFunc = Sms_Create_Opt_Handle;    // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_MATCHES_BODY, &FuncList, (void *)pMatchesBody);
} /* Sms_Create_Matches_Body */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Create_Matches_Body_OK(lv_obj_t *pBtn,lv_event_t event)
{
    // Matches_Body list call back function
    // go to Messages_Create_Message chart with Ta
    UINT32 i;
    UINT8  j;
    INT8   *pTemp;
    INT8   *pTemp1;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pTemp = lv_label_get_text((lv_obj_t *)pBtn->child_ll.head);

    i = strlen(pTemp);

    j  = strlen(g_MsgGlobalCtrl.pSmsText);
    i += j;

    if (i)
    {
        pTemp1 = Hal_Mem_Alloc(i + 1);
        Hal_Mem_Set(pTemp1, 0, i + 1);
        pTemp1 = strcat(pTemp1, g_MsgGlobalCtrl.pSmsText);
        pTemp1 = strcat(pTemp1, pTemp);
        Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
        g_MsgGlobalCtrl.pSmsText = NULL;
        g_MsgGlobalCtrl.pSmsText = pTemp1;
    }

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_CREATE_MESSAGE, NULL, NULL);
}
